<!DOCTYPE html>
<!-- saved from url=(0031)https://evileg.com/ru/post/512/ -->
<html lang="ru" itemscope="" itemtype="http://schema.org/Article"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="apple-touch-icon-precomposed" sizes="57x57" href="https://evileg.com/static/images/favicons/apple-touch-icon-57x57.png"><link rel="apple-touch-icon-precomposed" sizes="72x72" href="https://evileg.com/static/images/favicons/apple-touch-icon-72x72.png"><link rel="apple-touch-icon-precomposed" sizes="114x114" href="https://evileg.com/static/images/favicons/apple-touch-icon-114x114.png"><link rel="apple-touch-icon-precomposed" sizes="120x120" href="https://evileg.com/static/images/favicons/apple-touch-icon-120x120.png"><link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://evileg.com/static/images/favicons/apple-touch-icon-144x144.png"><link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://evileg.com/static/images/favicons/apple-touch-icon-152x152.png"><link title="EVILEG - Социальная сеть порграммистов" rel="alternate" type="application/rss+xml" href="https://evileg.com/ru/feed/"><link title="EVILEG - Форум" rel="alternate" type="application/rss+xml" href="https://evileg.com/ru/forum/feed/"><title>Поиск в ширину (Breadth first search, BFS)</title><meta property="og:title" content="Поиск в ширину (Breadth first search, BFS)"><meta property="og:type" content="website"><meta property="og:url" content="https://evileg.com/ru/post/512/"><meta property="og:image" content="https://evileg.com/static/images/favicons/favicon.ico"><meta property="og:site_name" content="EVILEG"><meta name="google-site-verification" content="vVTpO8SvQTo0QU2hU-zDTBHgHzqr2CGx7ACdQHPlLes"><meta name="yandex-verification" content="c58ddaad8c500539"><meta name="wot-verification" content="5e851b19f7a76433f3dc"><meta name="description" content="Поиск в ширину (Breadth first search, BFS). 
 
  
   Обход
  
  означает посещение всех узлов графа.
  
   «Обход в ширину» или «Поиск в ширину» (Breadth first traversal or Breadth first Search)
  
  - это рекурсивный алгоритм поиска всех верши"><link rel="stylesheet" href="./Поиск в ширину (Breadth first search, BFS)_files/css"><link rel="stylesheet" href="./Поиск в ширину (Breadth first search, BFS)_files/materialdesignicons.min.css" media="all" type="text/css"><link rel="stylesheet" href="./Поиск в ширину (Breadth first search, BFS)_files/cropper.min.css"><link rel="stylesheet" href="./Поиск в ширину (Breadth first search, BFS)_files/animate.min.css"><link rel="stylesheet" href="./Поиск в ширину (Breadth first search, BFS)_files/evileg_core.min.css"><script src="./Поиск в ширину (Breadth first search, BFS)_files/f.txt"></script><script type="text/javascript" async="" src="./Поиск в ширину (Breadth first search, BFS)_files/watch.js"></script><script src="./Поиск в ширину (Breadth first search, BFS)_files/f(1).txt" id="google_shimpl"></script><script type="text/javascript" src="./Поиск в ширину (Breadth first search, BFS)_files/context.js" async=""></script><script src="./Поиск в ширину (Breadth first search, BFS)_files/jquery-3.3.1.min.js"></script><script src="./Поиск в ширину (Breadth first search, BFS)_files/js.cookie.min.js"></script><script src="./Поиск в ширину (Breadth first search, BFS)_files/popper.min.js"></script><script src="./Поиск в ширину (Breadth first search, BFS)_files/evileg_core.min.js"></script><script defer="" src="./Поиск в ширину (Breadth first search, BFS)_files/cropper.min.js"></script><script defer="" src="./Поиск в ширину (Breadth first search, BFS)_files/evileg.min.js"></script><script defer="" src="./Поиск в ширину (Breadth first search, BFS)_files/global.min.js"></script><script defer="" src="./Поиск в ширину (Breadth first search, BFS)_files/markdown.min.js"></script><script defer="" src="./Поиск в ширину (Breadth first search, BFS)_files/bootstrap-notify.min.js"></script><script type="application/ld+json">{"@context": "http://schema.org", "@type": "ItemList", "itemListElement": [{"@type": "SiteNavigationElement", "position": 1, "name": "EVILEG", "url": "/ru/"}, {"@type": "SiteNavigationElement", "position": 2, "name": "Статьи", "url": "/ru/knowledge/"}, {"@type": "SiteNavigationElement", "position": 3, "name": "Форум", "url": "/ru/forum/"}, {"@type": "SiteNavigationElement", "position": 4, "name": "Тесты", "url": "/ru/tests/"}, {"@type": "SiteNavigationElement", "position": 5, "name": "Вакансии", "url": "/ru/vacancy/"}, {"@type": "SiteNavigationElement", "position": 6, "name": "Закладки", "url": "/ru/social_bookmarks/"}, {"@type": "SiteNavigationElement", "position": 7, "name": "Идеи", "url": "/ru/ideas/"}, {"@type": "SiteNavigationElement", "position": 8, "name": "Расшарить код", "url": "/ru/sharecode/"}, {"@type": "SiteNavigationElement", "position": 9, "name": "Компании", "url": "/ru/companies/"}, {"@type": "SiteNavigationElement", "position": 10, "name": "Пользователи", "url": "/ru/users/"}, {"@type": "SiteNavigationElement", "position": 11, "name": "Расшарить код", "url": "/ru/sharecode/create/"}, {"@type": "SiteNavigationElement", "position": 12, "name": "Написать статью", "url": "/ru/knowledge/article/add/"}, {"@type": "SiteNavigationElement", "position": 13, "name": "Задать вопрос", "url": "/ru/forum/create_topic/"}]}</script><meta http-equiv="origin-trial" content="AxujKG9INjsZ8/gUq8+dTruNvk7RjZQ1oFhhgQbcTJKDnZfbzSTE81wvC2Hzaf3TW4avA76LTZEMdiedF1vIbA4AAABueyJvcmlnaW4iOiJodHRwczovL2ltYXNkay5nb29nbGVhcGlzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0="><meta http-equiv="origin-trial" content="Azuce85ORtSnWe1MZDTv68qpaW3iHyfL9YbLRy0cwcCZwVnePnOmkUJlG8HGikmOwhZU22dElCcfrfX2HhrBPAkAAAB7eyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A16nvcdeoOAqrJcmjLRpl1I6f3McDD8EfofAYTt/P/H4/AWwB99nxiPp6kA0fXoiZav908Z8etuL16laFPUdfQsAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="AxBHdr0J44vFBQtZUqX9sjiqf5yWZ/OcHRcRMN3H9TH+t90V/j3ENW6C8+igBZFXMJ7G3Pr8Dd13632aLng42wgAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A88BWHFjcawUfKU3lIejLoryXoyjooBXLgWmGh+hNcqMK44cugvsI5YZbNarYvi3roc1fYbHA1AVbhAtuHZflgEAAAB2eyJvcmlnaW4iOiJodHRwczovL2dvb2dsZS5jb206NDQzIiwiZmVhdHVyZSI6IlRydXN0VG9rZW5zIiwiZXhwaXJ5IjoxNjUyNzc0NDAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="A8FHS1NmdCwGqD9DwOicnHHY+y27kdWfxKa0YHSGDfv0CSpDKRHTQdQmZVPDUdaFWUsxdgVxlwAd6o+dhJykPA0AAACWeyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A8zdXi6dr1hwXEUjQrYiyYQGlU3557y5QWDnN0Lwgj9ePt66XMEvNkVWOEOWPd7TP9sBQ25X0Q15Lr1Nn4oGFQkAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A4/Htern2udN9w3yJK9QgWQxQFruxOXsXL7cW60DyCl0EZFGCSme/J33Q/WzF7bBkVvhEWDlcBiUyZaim5CpFQwAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="AxujKG9INjsZ8/gUq8+dTruNvk7RjZQ1oFhhgQbcTJKDnZfbzSTE81wvC2Hzaf3TW4avA76LTZEMdiedF1vIbA4AAABueyJvcmlnaW4iOiJodHRwczovL2ltYXNkay5nb29nbGVhcGlzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0="><meta http-equiv="origin-trial" content="Azuce85ORtSnWe1MZDTv68qpaW3iHyfL9YbLRy0cwcCZwVnePnOmkUJlG8HGikmOwhZU22dElCcfrfX2HhrBPAkAAAB7eyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A16nvcdeoOAqrJcmjLRpl1I6f3McDD8EfofAYTt/P/H4/AWwB99nxiPp6kA0fXoiZav908Z8etuL16laFPUdfQsAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="AxBHdr0J44vFBQtZUqX9sjiqf5yWZ/OcHRcRMN3H9TH+t90V/j3ENW6C8+igBZFXMJ7G3Pr8Dd13632aLng42wgAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A88BWHFjcawUfKU3lIejLoryXoyjooBXLgWmGh+hNcqMK44cugvsI5YZbNarYvi3roc1fYbHA1AVbhAtuHZflgEAAAB2eyJvcmlnaW4iOiJodHRwczovL2dvb2dsZS5jb206NDQzIiwiZmVhdHVyZSI6IlRydXN0VG9rZW5zIiwiZXhwaXJ5IjoxNjUyNzc0NDAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="A8FHS1NmdCwGqD9DwOicnHHY+y27kdWfxKa0YHSGDfv0CSpDKRHTQdQmZVPDUdaFWUsxdgVxlwAd6o+dhJykPA0AAACWeyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A8zdXi6dr1hwXEUjQrYiyYQGlU3557y5QWDnN0Lwgj9ePt66XMEvNkVWOEOWPd7TP9sBQ25X0Q15Lr1Nn4oGFQkAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A4/Htern2udN9w3yJK9QgWQxQFruxOXsXL7cW60DyCl0EZFGCSme/J33Q/WzF7bBkVvhEWDlcBiUyZaim5CpFQwAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="AxujKG9INjsZ8/gUq8+dTruNvk7RjZQ1oFhhgQbcTJKDnZfbzSTE81wvC2Hzaf3TW4avA76LTZEMdiedF1vIbA4AAABueyJvcmlnaW4iOiJodHRwczovL2ltYXNkay5nb29nbGVhcGlzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0="><meta http-equiv="origin-trial" content="Azuce85ORtSnWe1MZDTv68qpaW3iHyfL9YbLRy0cwcCZwVnePnOmkUJlG8HGikmOwhZU22dElCcfrfX2HhrBPAkAAAB7eyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A16nvcdeoOAqrJcmjLRpl1I6f3McDD8EfofAYTt/P/H4/AWwB99nxiPp6kA0fXoiZav908Z8etuL16laFPUdfQsAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="AxBHdr0J44vFBQtZUqX9sjiqf5yWZ/OcHRcRMN3H9TH+t90V/j3ENW6C8+igBZFXMJ7G3Pr8Dd13632aLng42wgAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A88BWHFjcawUfKU3lIejLoryXoyjooBXLgWmGh+hNcqMK44cugvsI5YZbNarYvi3roc1fYbHA1AVbhAtuHZflgEAAAB2eyJvcmlnaW4iOiJodHRwczovL2dvb2dsZS5jb206NDQzIiwiZmVhdHVyZSI6IlRydXN0VG9rZW5zIiwiZXhwaXJ5IjoxNjUyNzc0NDAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="A8FHS1NmdCwGqD9DwOicnHHY+y27kdWfxKa0YHSGDfv0CSpDKRHTQdQmZVPDUdaFWUsxdgVxlwAd6o+dhJykPA0AAACWeyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A8zdXi6dr1hwXEUjQrYiyYQGlU3557y5QWDnN0Lwgj9ePt66XMEvNkVWOEOWPd7TP9sBQ25X0Q15Lr1Nn4oGFQkAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A4/Htern2udN9w3yJK9QgWQxQFruxOXsXL7cW60DyCl0EZFGCSme/J33Q/WzF7bBkVvhEWDlcBiUyZaim5CpFQwAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="AxujKG9INjsZ8/gUq8+dTruNvk7RjZQ1oFhhgQbcTJKDnZfbzSTE81wvC2Hzaf3TW4avA76LTZEMdiedF1vIbA4AAABueyJvcmlnaW4iOiJodHRwczovL2ltYXNkay5nb29nbGVhcGlzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0="><meta http-equiv="origin-trial" content="Azuce85ORtSnWe1MZDTv68qpaW3iHyfL9YbLRy0cwcCZwVnePnOmkUJlG8HGikmOwhZU22dElCcfrfX2HhrBPAkAAAB7eyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A16nvcdeoOAqrJcmjLRpl1I6f3McDD8EfofAYTt/P/H4/AWwB99nxiPp6kA0fXoiZav908Z8etuL16laFPUdfQsAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="AxBHdr0J44vFBQtZUqX9sjiqf5yWZ/OcHRcRMN3H9TH+t90V/j3ENW6C8+igBZFXMJ7G3Pr8Dd13632aLng42wgAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A88BWHFjcawUfKU3lIejLoryXoyjooBXLgWmGh+hNcqMK44cugvsI5YZbNarYvi3roc1fYbHA1AVbhAtuHZflgEAAAB2eyJvcmlnaW4iOiJodHRwczovL2dvb2dsZS5jb206NDQzIiwiZmVhdHVyZSI6IlRydXN0VG9rZW5zIiwiZXhwaXJ5IjoxNjUyNzc0NDAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="A8FHS1NmdCwGqD9DwOicnHHY+y27kdWfxKa0YHSGDfv0CSpDKRHTQdQmZVPDUdaFWUsxdgVxlwAd6o+dhJykPA0AAACWeyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A8zdXi6dr1hwXEUjQrYiyYQGlU3557y5QWDnN0Lwgj9ePt66XMEvNkVWOEOWPd7TP9sBQ25X0Q15Lr1Nn4oGFQkAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="A4/Htern2udN9w3yJK9QgWQxQFruxOXsXL7cW60DyCl0EZFGCSme/J33Q/WzF7bBkVvhEWDlcBiUyZaim5CpFQwAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjQzMTU1MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><link rel="stylesheet" type="text/css" href="./Поиск в ширину (Breadth first search, BFS)_files/prettify.css"><link rel="preload" href="./Поиск в ширину (Breadth first search, BFS)_files/f(2).txt" as="script"><script type="text/javascript" src="./Поиск в ширину (Breadth first search, BFS)_files/f(2).txt"></script><link rel="preload" href="./Поиск в ширину (Breadth first search, BFS)_files/f(3).txt" as="script"><script type="text/javascript" src="./Поиск в ширину (Breadth first search, BFS)_files/f(3).txt"></script><script charset="utf-8" src="./Поиск в ширину (Breadth first search, BFS)_files/f8af04246520396c3722.js" crossorigin="anonymous" importance="high"></script><script charset="utf-8" src="./Поиск в ширину (Breadth first search, BFS)_files/999b92812ceab9de3d7c.js" crossorigin="anonymous" importance="high"></script><script async="" crossorigin="anonymous" src="./Поиск в ширину (Breadth first search, BFS)_files/host.js"></script><link rel="preconnect" href="https://yastatic.net/"><link rel="preconnect" href="https://avatars.mds.yandex.net/"><link rel="preconnect" href="https://mc.yandex.ru/"><meta id="https://yastatic.net/partner-code-bundles/57153/context_static.js"><link rel="preconnect" href="https://ads.adfox.ru/"><script charset="utf-8" src="./Поиск в ширину (Breadth first search, BFS)_files/b260d1d104887197a0a2.js" crossorigin="anonymous" importance="high"></script><style type="text/css">.ica4f4aee{opacity: !important;white-space:normal !important;visibility:visible !important}.ica4f4aee,.ica4f4aee yatag{display:block !important;font-family:inherit !important}.ica4f4aee,.ica4f4aee,.ica4f4aee a,.ica4f4aee b,.ica4f4aee em,.ica4f4aee iframe,.ica4f4aee img,.ica4f4aee table,.ica4f4aee tbody,.ica4f4aee td,.ica4f4aee tr,.ica4f4aee yatag{-webkit-box-sizing:content-box !important;box-sizing:content-box !important;color:inherit !important;font-size:inherit !important;font-weight:inherit !important;-webkit-hyphens:manual !important;-ms-hyphens:manual !important;hyphens:manual !important;-webkit-transition:none !important;-o-transition:none !important;transition:none !important}.ica4f4aee,.ica4f4aee a,.ica4f4aee b,.ica4f4aee em,.ica4f4aee iframe,.ica4f4aee img,.ica4f4aee table,.ica4f4aee tbody,.ica4f4aee td,.ica4f4aee tr{background:none !important;border:none !important;border-radius:0 !important;border-spacing:0 !important;border-collapse:collapse !important;clear:none !important;float:none !important;font-variant:normal !important;letter-spacing:normal !important;line-height:normal !important;margin:0 !important;max-height:none !important;max-width:none !important;min-height:0 !important;min-width:0 !important;outline:none !important;padding:0 !important;position:static !important;text-align:left !important;text-decoration:none !important;text-indent:0 !important;text-transform:none !important;vertical-align:baseline !important;visibility:inherit !important;word-spacing:normal !important}.ica4f4aee,.ica4f4aee a,.ica4f4aee b,.ica4f4aee em,.ica4f4aee img,.ica4f4aee table,.ica4f4aee tbody,.ica4f4aee td,.ica4f4aee tr{height:auto !important}.ica4f4aee table{display:table !important;empty-cells:hide !important;table-layout:fixed !important}.ica4f4aee table,.ica4f4aee td{font-size:100% !important}.ica4f4aee td{display:table-cell !important;vertical-align:middle !important}.ica4f4aee{width:auto !important;height:auto !important;overflow:visible !important}.ica4f4aee .d4a383bae{position:relative !important;margin:auto !important;display:-webkit-box !important;display:-ms-flexbox !important;display:flex !important;-webkit-box-pack:center !important;-ms-flex-pack:center !important;justify-content:center !important;-webkit-box-align:center !important;-ms-flex-align:center !important;align-items:center !important;overflow:hidden !important}.ica4f4aee .o95fd1e8e{padding:10px 16px 86px !important}.ica4f4aee .j9b152b41,.ica4f4aee .bc83ae63{position:absolute !important;z-index:1 !important;top:0 !important;left:0 !important;right:0 !important;bottom:0 !important;width:100% !important;height:100% !important;display:none !important}.ica4f4aee .g45379729{position:relative !important;z-index:2 !important}.ica4f4aee .e927bf79e{position:relative !important;top:0 !important;left:0 !important;width:100% !important;height:100% !important}.ica4f4aee .e927bf79e iframe{position:absolute !important;top:0 !important;left:0 !important;width:100% !important;height:100% !important}.ica4f4aee .p98e7ad81{position:absolute !important;width:100% !important;right:0 !important;top:0 !important;z-index:20 !important}.ica4f4aee .a496c199{position:absolute !important;z-index:21 !important;top:0 !important;left:0 !important;width:100% !important;height:100% !important}.ica4f4aee .wc1bd14eb{position:absolute !important;top:0 !important;left:0 !important;z-index:10 !important;height:16px !important;padding:0 4px !important;font-size:11px !important;line-height:16px !important;color:#000 !important;text-decoration:none !important;background:#fff !important;border:1px solid #e5e5e5 !important;border-bottom-right-radius:3px !important;cursor:pointer !important}.ica4f4aee .o7b697c2f{border:1px solid #303050 !important}.ica4f4aee .wbd22bcb{max-width:100% !important;max-height:100% !important}.ica4f4aee .wbd22bcb .j9b152b41,.ica4f4aee .wbd22bcb .bc83ae63{display:block !important}.ica4f4aee .wbd22bcb .bc83ae63{-webkit-filter:blur(10px) saturate(0) contrast(400%) !important;filter:blur(10px) saturate(0) contrast(400%) !important}.ica4f4aee .wbd22bcb .j9b152b41{background-color:rgba(38,38,38,.9) !important}.ica4f4aee .b19c557ed{-webkit-box-pack:start !important;-ms-flex-pack:start !important;justify-content:flex-start !important}.ica4f4aee .u5fee9959,.ica4f4aee .rc38e9c31{visibility:hidden !important;opacity:0 !important}.ica4f4aee .rc38e9c31{max-width:1px !important;max-height:1px !important}.ica4f4aee .e944520eb{position:absolute !important;bottom:20px !important;left:16px !important;right:16px !important;z-index:3 !important;display:-webkit-box !important;display:-ms-flexbox !important;display:flex !important}@media (orientation:landscape){.ica4f4aee .e944520eb{margin:0 auto !important;width:260px !important}}.ica4f4aee .x4d031db8{height:48px !important;line-height:48px !important;font-size:16px !important;border-radius:8px !important;text-align:center !important;font-weight:700 !important;-ms-flex-item-align:stretch !important;align-self:stretch !important;padding:0 20px !important;white-space:nowrap !important;min-width:0 !important}.ica4f4aee .ge3eeb5c3{background:-webkit-gradient(linear,left top,left bottom,from(#efefef),to(#e5e5e5)) !important;background:-o-linear-gradient(top,#efefef 0,#e5e5e5 100%) !important;background:linear-gradient(180deg,#efefef,#e5e5e5) !important;margin-right:8px !important;-webkit-box-flex:2 !important;-ms-flex:2 1 !important;flex:2 1 !important}.ica4f4aee .r99e1fc9d{background:-webkit-gradient(linear,left top,right top,color-stop(-40%,#f60),color-stop(20%,rgba(255,102,0,0))),-webkit-gradient(linear,right top,left top,color-stop(-40%,#f60),color-stop(20%,rgba(255,102,0,0))),-webkit-gradient(linear,left bottom,left top,color-stop(-80%,#f60),color-stop(80%,#fd0)) !important;background:-o-linear-gradient(left,#f60 -40%,rgba(255,102,0,0) 20%),-o-linear-gradient(right,#f60 -40%,rgba(255,102,0,0) 20%),-o-linear-gradient(bottom,#f60 -80%,#fd0 80%) !important;background:linear-gradient(90deg,#f60 -40%,rgba(255,102,0,0) 20%),linear-gradient(270deg,#f60 -40%,rgba(255,102,0,0) 20%),linear-gradient(0deg,#f60 -80%,#fd0 80%) !important;-webkit-box-flex:3 !important;-ms-flex:3 1 !important;flex:3 1 !important}.ica4f4aee .g7b2847f7{display:inline-block !important;margin-left:8px !important}.ica4f4aee .h7b9b479e{position:absolute !important;left:-1000px !important;top:-1000px !important;width:1px !important;height:1px !important;display:block !important}.ica4f4aee .kaea8864a{cursor:pointer !important;position:absolute !important;right:4px !important;top:4px !important;z-index:10 !important}.ica4f4aee .ee9c6d55f.kaea8864a{display:-webkit-box !important;display:-ms-flexbox !important;display:flex !important;-webkit-box-align:center !important;-ms-flex-align:center !important;align-items:center !important;-webkit-box-pack:center !important;-ms-flex-pack:center !important;justify-content:center !important;pointer-events:auto !important;border-radius:50% !important;-webkit-user-select:none !important;-moz-user-select:none !important;-ms-user-select:none !important;user-select:none !important;-webkit-tap-highlight-color:transparent !important}.ica4f4aee .ee9c6d55f.kaea8864a:before{content:"" !important;position:absolute !important;top:-4px !important;left:50% !important;-webkit-transform:translateX(-50%) !important;transform:translateX(-50%) !important}.ica4f4aee .ee9c6d55f.kaea8864a:hover .nda367efa{opacity:.8 !important}.ica4f4aee .ee9c6d55f.kaea8864a.hb7f535f1 .nda367efa{background-color:#fff !important;opacity:.8 !important}.ica4f4aee .ee9c6d55f.kaea8864a.hb7f535f1 .s719bafb4 svg{fill:#575c66 !important}.ica4f4aee .ee9c6d55f.kaea8864a.re8ba0969,.ica4f4aee .ee9c6d55f.kaea8864a.x518418b{-webkit-backdrop-filter:none !important;backdrop-filter:none !important}.ica4f4aee .ee9c6d55f.kaea8864a.re8ba0969 .nda367efa,.ica4f4aee .ee9c6d55f.kaea8864a.x518418b .nda367efa{background:none !important}.ica4f4aee .ee9c6d55f.kaea8864a.re8ba0969 .s719bafb4,.ica4f4aee .ee9c6d55f.kaea8864a.x518418b .s719bafb4{-webkit-filter:none !important;filter:none !important}.ica4f4aee .ee9c6d55f.kaea8864a.re8ba0969:hover{background-color:#e9e9e9 !important}.ica4f4aee .ee9c6d55f.kaea8864a.re8ba0969 .s719bafb4 svg{fill:#242526 !important}.ica4f4aee .ee9c6d55f.kaea8864a.re8ba0969 .v8933a008{color:#242526 !important}.ica4f4aee .ee9c6d55f.kaea8864a.x518418b:hover{background-color:rgba(248,250,255,.2) !important}.ica4f4aee .ee9c6d55f.kaea8864a.x518418b .s719bafb4 svg{fill:#fff !important}.ica4f4aee .ee9c6d55f.kaea8864a.x518418b .v8933a008{color:#fff !important}.ica4f4aee .ee9c6d55f.wd47bec24{width:12px !important;height:12px !important}.ica4f4aee .ee9c6d55f.wd47bec24:before{width:28px !important;height:28px !important}.ica4f4aee .ee9c6d55f.wd47bec24 .s719bafb4{-webkit-transform:scale(.6) !important;transform:scale(.6) !important}.ica4f4aee .ee9c6d55f.k19481c{width:16px !important;height:16px !important}.ica4f4aee .ee9c6d55f.k19481c:before{width:32px !important;height:32px !important}.ica4f4aee .ee9c6d55f.k19481c .s719bafb4{-webkit-transform:scale(.8) !important;transform:scale(.8) !important}.ica4f4aee .ee9c6d55f.g19836842{width:24px !important;height:24px !important}.ica4f4aee .ee9c6d55f.g19836842:before{width:42px !important;height:42px !important}.ica4f4aee .ee9c6d55f.r4ccd12a3{width:28px !important;height:28px !important}.ica4f4aee .ee9c6d55f.r4ccd12a3:before{width:42px !important;height:42px !important}.ica4f4aee .nda367efa{height:100% !important;width:100% !important;position:absolute !important;top:0 !important;left:0 !important;z-index:-1 !important;opacity:.6 !important;border-radius:inherit !important;-webkit-transition:opacity .15s !important;-o-transition:opacity .15s !important;transition:opacity .15s !important;-webkit-transition:background-color .5s ease-in-out !important;-o-transition:background-color .5s ease-in-out !important;transition:background-color .5s ease-in-out !important}.ica4f4aee .ee9c6d55f .s719bafb4{display:-webkit-box !important;display:-ms-flexbox !important;display:flex !important;-webkit-box-align:center !important;-ms-flex-align:center !important;align-items:center !important;-webkit-box-pack:center !important;-ms-flex-pack:center !important;justify-content:center !important;pointer-events:none !important}.ica4f4aee .ee9c6d55f .s719bafb4.l554188f5 svg{fill:#fff !important}.ica4f4aee .ee9c6d55f .s719bafb4.l554188f5 svg,.ica4f4aee .ee9c6d55f .s719bafb4.q60b12f97 svg{-webkit-transition:fill .5s ease-in-out !important;-o-transition:fill .5s ease-in-out !important;transition:fill .5s ease-in-out !important}.ica4f4aee .ee9c6d55f .s719bafb4.q60b12f97 svg{fill:#242526 !important}.ica4f4aee .v8933a008{display:-webkit-box !important;display:-ms-flexbox !important;display:flex !important;-webkit-box-align:center !important;-ms-flex-align:center !important;align-items:center !important;-webkit-box-pack:center !important;-ms-flex-pack:center !important;justify-content:center !important;pointer-events:none !important}.ica4f4aee .v8933a008.l554188f5{color:#fff !important}.ica4f4aee .v8933a008.q60b12f97{color:#242526 !important}@-webkit-keyframes f6b3f3c5a{0%,to{opacity:0 !important;visibility:hidden !important}4%,96%{visibility:visible !important;opacity:1 !important}}@keyframes f6b3f3c5a{0%,to{opacity:0 !important;visibility:hidden !important}4%,96%{visibility:visible !important;opacity:1 !important}}@media (hover:hover) and (pointer:fine){.ica4f4aee .a15707efb:hover .cb5dbb7e0{opacity:0 !important;visibility:hidden !important}.ica4f4aee .a15707efb:hover .jc83b1f95{visibility:visible !important;opacity:1 !important}.ica4f4aee .a15707efb[data-active]:hover .jc83b1f95{opacity:0 !important;visibility:hidden !important}.ica4f4aee .a15707efb[data-active]:hover .cb5dbb7e0{visibility:visible !important;opacity:1 !important}}.ica4f4aee .a15707efb.k5469e74b{right:45px !important}.ica4f4aee .a15707efb.k5469e74b .j63b4ad20.cb5dbb7e0{-webkit-transform:translateX(41px) !important;transform:translateX(41px) !important}.ica4f4aee .a15707efb.k5469e74b .j63b4ad20.cb5dbb7e0 .bc7707459{-webkit-transform:translateX(-43px) !important;transform:translateX(-43px) !important}.ica4f4aee .a15707efb{right:36px !important;width:32px !important}.ica4f4aee .a15707efb[data-active] svg{color:#ee4f4f !important;fill:#ee4f4f !important}.ica4f4aee .a15707efb[data-active] .cb5dbb7e0{-webkit-animation:f6b3f3c5a 8s linear !important;animation:f6b3f3c5a 8s linear !important}.ica4f4aee .a15707efb .j63b4ad20{position:absolute !important;color:#fff !important;opacity:0 !important;visibility:hidden !important;white-space:nowrap !important;top:29px !important;right:50% !important;-webkit-transform:translateX(50%) !important;transform:translateX(50%) !important;background:#343334 !important;border-radius:6px !important;padding:0 8px !important;height:24px !important;line-height:24px !important;font-size:11px !important;-webkit-transition:all .2s !important;-o-transition:all .2s !important;transition:all .2s !important}.ica4f4aee .a15707efb .j63b4ad20.cb5dbb7e0{-webkit-transform:translateX(32px) !important;transform:translateX(32px) !important;right:0 !important}.ica4f4aee .a15707efb .j63b4ad20.cb5dbb7e0 .bc7707459{right:0 !important;-webkit-transform:translateX(-34px) !important;transform:translateX(-34px) !important}.ica4f4aee .a15707efb .j63b4ad20 .oef11235d{font-size:11px !important}.ica4f4aee .a15707efb .j63b4ad20 .bc7707459{width:28px !important;height:8px !important;position:absolute !important;top:-6px !important;right:50% !important;-webkit-transform:translateX(50%) !important;transform:translateX(50%) !important;display:-webkit-box !important;display:-ms-flexbox !important;display:flex !important;-webkit-box-align:center !important;-ms-flex-align:center !important;align-items:center !important;-webkit-box-pack:center !important;-ms-flex-pack:center !important;justify-content:center !important}.ica4f4aee .a15707efb .j63b4ad20 .qe6c72500{color:#ffd400 !important;text-decoration:none !important;text-transform:lowercase !important}.ica4f4aee .i92e83db3{height:100% !important;width:100% !important;position:absolute !important;top:0 !important;left:0 !important;z-index:-1 !important;opacity:.6 !important;border-radius:inherit !important;-webkit-transition:background-color .5s ease-in-out !important;-o-transition:background-color .5s ease-in-out !important;transition:background-color .5s ease-in-out !important}.ica4f4aee .keccaa516{display:-webkit-box !important;display:-ms-flexbox !important;display:flex !important;cursor:pointer !important;position:absolute !important;left:4px !important;top:4px !important;z-index:10 !important;font-family:Helvetica,Arial,sans-serif !important;height:12px !important;-webkit-box-sizing:border-box !important;box-sizing:border-box !important;line-height:9px !important;padding:2px 4px !important;color:hsla(0,0%,100%,.8) !important;border-radius:16px !important;font-size:7px !important;text-transform:uppercase !important;letter-spacing:.125em !important;text-shadow:0 1px 1px rgba(0,0,0,.05),0 2px 2px rgba(0,0,0,.05),0 4px 4px rgba(0,0,0,.05),0 0 8px rgba(0,0,0,.05) !important;pointer-events:none !important;-webkit-transition:color .5s ease-in-out !important;-o-transition:color .5s ease-in-out !important;transition:color .5s ease-in-out !important}.ica4f4aee .keccaa516,.ica4f4aee .keccaa516>a{text-decoration:none !important}.ica4f4aee .keccaa516>a{color:inherit !important}.ica4f4aee .keccaa516.hb7f535f1{color:#575c66 !important}.ica4f4aee .keccaa516.hb7f535f1 .i92e83db3{background-color:#fff !important;opacity:.8 !important}.ica4f4aee .keccaa516.re8ba0969,.ica4f4aee .keccaa516.q60b12f97{color:#575c66 !important}.ica4f4aee .keccaa516.l554188f5,.ica4f4aee .keccaa516.x518418b{color:#fff !important}.ica4f4aee .keccaa516.o39a4a7f6,.ica4f4aee .keccaa516.ndcd6a54a{top:auto !important;left:auto !important;right:0 !important;bottom:0 !important;background:none !important;text-shadow:none !important;font-size:7px !important;padding:0 !important;line-height:normal !important;height:auto !important;opacity:.8 !important;-webkit-backdrop-filter:none !important;backdrop-filter:none !important}@media not all and (min-resolution:0.001dpcm){@supports (-webkit-appearance:none){.ica4f4aee .keccaa516{text-shadow:0 1px 2px rgba(0,0,0,.15) !important}}}@supports ((-webkit-backdrop-filter:blur(16px)) or (backdrop-filter:blur(16px))){.ica4f4aee .nda367efa,.ica4f4aee .i92e83db3{opacity:.1 !important}.ica4f4aee .ee9c6d55f.kaea8864a,.ica4f4aee .keccaa516{-webkit-backdrop-filter:blur(16px) !important;backdrop-filter:blur(16px) !important}.ica4f4aee .ee9c6d55f.kaea8864a:not(.ee9c6d55f.kaea8864a.hb7f535f1):hover .nda367efa{opacity:.4 !important}}.ica4f4aee .vc7690cb9{margin:0 2px !important}.ica4f4aee .m63c59575{text-decoration:none !important;pointer-events:auto !important;color:inherit !important}</style><style nonce="">#7f73ea1177{width:1px;height:1px;position:relative;}</style><style nonce="">#id6875{width:1px;height:1px;top:0px;left:0px;position:absolute;}</style><style nonce="">#ya_partner_R-A-218837-2{width:100%;height:100%;position:relative;}</style><style nonce="">#id5079{width:100%;height:100%;top:0px;left:0px;position:absolute;}</style></head><body class="body"><div class="modal fade" id="menuModal" tabindex="-1" aria-hidden="true"><div class="modal-dialog modal-lg w-auto modal-content"><div class="modal-header"><span>Выбрать раздел</span><span class="mdi mdi-24px mdi-window-close mdi-0 pointer" data-dismiss="modal" aria-label="Close"></span></div><div class="modal-body"><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/knowledge/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-newspaper mdi-0"></span></div><small>Статьи</small></div></div></a><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/forum/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-forum mdi-0"></span></div><small>Форум</small></div></div></a><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/tests/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-format-list-checks mdi-0"></span></div><small>Тесты</small></div></div></a><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/vacancy/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-briefcase mdi-0"></span></div><small>Вакансии</small></div></div></a><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/social_bookmarks/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-bookmark mdi-0"></span></div><small>Закладки</small></div></div></a><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/forum/ideas/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-lightbulb-on mdi-0"></span></div><small>Идеи</small></div></div></a><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/sharecode/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-share-variant mdi-0"></span></div><small>Расшарить код</small></div></div></a><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/companies/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-office-building mdi-0"></span></div><small>Компании</small></div></div></a><a class="btn btn-dark btn-menu" href="https://evileg.com/ru/users/"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-account-group mdi-0"></span></div><small>Пользователи</small></div></div></a></div></div></div><div id="drawer" class="drawer drawer-closed box-shadow"><nav class="mb-2 drawer-nav"><div class="p-3"><form class="m-0" action="https://evileg.com/ru/accounts/login/" method="post"><input type="hidden" name="csrfmiddlewaretoken" value="tpNu7BNAqvCjpCsMNMUYk4LuUofKzitHCWS9tJdLVbp4yTMsHzZ90KUTBmOtsClt"><div class="form-group"><label for="id_username">Имя пользователя</label><input type="text" name="username" autofocus="" autocapitalize="none" autocomplete="username" maxlength="150" class="form-control" placeholder="Имя пользователя или email" title="" required="" id="id_username"></div><div class="form-group"><label for="id_password">Пароль</label><input type="password" name="password" autocomplete="current-password" class="form-control" placeholder="Пароль" title="" required="" id="id_password"></div><button type="submit" class="btn btn-sm btn-primary btn-raised mdi mdi-login">Войти</button><div class="mt-2 mb-1"><small><a href="https://evileg.com/ru/accounts/register/">Зарегистрироваться</a> -
            <a href="https://evileg.com/ru/accounts/forgot/">Забыли пароль?</a> -
            <a href="https://evileg.com/ru/accounts/activate/">Активировать аккаунт</a></small></div><small class="text-secondary">Войти с помощью социальной сети</small><div style="line-height: initial;"><a href="https://evileg.com/login/vk-oauth2/" class="mdi mdi-vk-box mdi-48px vk-color"></a><a href="https://evileg.com/login/google-oauth2/" class="mdi mdi-google-plus-box mdi-48px google-color"></a><a href="https://evileg.com/login/facebook/" class="mdi mdi-facebook-box mdi-48px fb-color"></a><a href="https://evileg.com/login/github/" class="mdi mdi-github-box mdi-48px github-color"></a></div></form></div><form action="https://evileg.com/ru/search/" class="m-0 p-0 border-bottom border-top" method="get"><div class="input-group"><input id="search" name="search" type="search" class="form-control px-3 border-0" placeholder="Поиск..."></div></form><div class="drawer_items_list border-0"><a href="https://evileg.com/ru/sharecode/create/"><span>Расшарить код</span></a><a href="https://evileg.com/ru/knowledge/article/add/"><span>Написать статью</span></a><a href="https://evileg.com/ru/forum/create_topic/"><span>Задать вопрос</span></a><a href="https://evileg.com/ru/tests/"><span>Пройти тест</span></a></div></nav></div><header class="fixed-top header box-shadow"><nav class="navbar navbar-expand navbar-light bg-white"><ul class="navbar-nav mr-0"><button class="navbar-toggler mr-4 d-block d-xl-none border" type="button" onclick="$(&#39;body&#39;).toggleDrawer();"><span class="navbar-toggler-icon"></span></button><li class="nav-item mr-auto mr-sm-0"><a href="https://evileg.com/ru/" class="navbar-brand">EVILEG</a></li></ul><div class="navbar-nav d-none d-sm-flex flex-wrap overflow-hidden"><a class="nav-link" href="https://evileg.com/ru/knowledge/">Статьи</a><a class="nav-link" href="https://evileg.com/ru/forum/">Форум</a><a class="nav-link" href="https://evileg.com/ru/tests/">Тесты</a><a class="nav-link" href="https://evileg.com/ru/vacancy/">Вакансии</a><a class="nav-link" href="https://evileg.com/ru/social_bookmarks/">Закладки</a><a class="nav-link" href="https://evileg.com/ru/forum/ideas/">Идеи</a><a class="nav-link" href="https://evileg.com/ru/sharecode/">Расшарить код</a><a class="nav-link" href="https://evileg.com/ru/companies/">Компании</a><a class="nav-link" href="https://evileg.com/ru/users/">Пользователи</a></div><ul class="navbar-nav ml-auto"><li class="nav-item mr-1"><a class="nav-link mdi mdi-36px mdi-apps p-0 pointer" style="margin-top: -6px; margin-bottom: -14px;" data-toggle="modal" data-target="#menuModal"></a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle border lang-btn" href="https://evileg.com/ru/post/512/#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">ru</a><div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"><a class="dropdown-item" href="https://evileg.com/lang/ru/">Русский</a><a class="dropdown-item" href="https://evileg.com/lang/uk/">Українська</a><a class="dropdown-item" href="https://evileg.com/lang/en/">English</a><a class="dropdown-item" href="https://evileg.com/lang/de/">Deutsch</a></div></li></ul></nav></header><main class="container-fluid px-0 mx-0 row" style="height: auto !important;"><div class="col-12 col-lg-9 px-0 border-right border-bottom" style="height: auto !important; min-height: 0px !important;"><ul class="breadcrumb bg-light"><li class="breadcrumb-item"><a href="https://evileg.com/ru/"><span class="mdi mdi-home mdi-0"><span class="d-none">EVILEG</span></span></a></li><li class="breadcrumb-item"><a href="https://evileg.com/ru/knowledge/">Статьи</a></li><li class="breadcrumb-item"><a href="https://evileg.com/ru/knowledge/algorithms/">Алгоритмы</a></li><li class="breadcrumb-item active">Поиск в ширину (Breadth first search, BFS)</li></ul><script type="application/ld+json">{"@context": "http://schema.org", "@type": "BreadcrumbList", "itemListElement": [{"@type": "ListItem", "position": 1, "item": {"@type": "Thing", "@id": "/ru/", "name": "EVILEG"}}, {"@type": "ListItem", "position": 2, "item": {"@type": "Thing", "@id": "/ru/knowledge/", "name": "Статьи"}}, {"@type": "ListItem", "position": 3, "item": {"@type": "Thing", "@id": "/ru/knowledge/algorithms/", "name": "Алгоритмы"}}, {"@type": "ListItem", "position": 4, "item": {"@type": "Thing", "@id": "/ru/post/512/", "name": "Поиск в ширину (Breadth first search, BFS)"}}]}</script><div style="height: auto !important;"><article style="height: auto !important;"><div itemprop="publisher" itemscope="" itemtype="https://schema.org/Organization"><div itemprop="logo" itemscope="" itemtype="https://schema.org/ImageObject"><link itemprop="image" href="https://evileg.com/static/images/favicons/apple-touch-icon-152x152.png"><link itemprop="url" href="https://evileg.com/static/images/favicons/apple-touch-icon-152x152.png"><meta itemprop="width" content="152"><meta itemprop="height" content="152"></div><meta itemprop="name" content="EVILEG"><meta itemprop="address" content="EVILEG"><meta itemprop="telephone" content="-"><link itemprop="url" href="https://evileg.com/"></div><link itemprop="mainEntityOfPage" itemscope="" href="https://evileg.com/ru/post/512/"><meta itemprop="commentCount" content="1"><meta itemprop="articleSection" content="Алгоритмы"><div itemscope="" itemprop="author" itemtype="https://schema.org/Person"><meta itemprop="name" content="mafulechka"><link itemprop="url" content="/ru/users/mafulechka/"></div><meta itemprop="url" content="/ru/post/512/"><meta itemprop="accessMode" content="textual"><meta itemprop="wordCount" content="1205"><meta itemprop="datePublished" content="16 июля 2019 г. 16:03"><meta itemprop="dateModified" content="19 июня 2020 г. 3:02"><div itemprop="interactionStatistic" itemscope="" itemtype="https://schema.org/InteractionCounter"><meta itemprop="interactionType" content="https://schema.org/BookmarkAction"><meta itemprop="userInteractionCount" content="0"></div><div itemprop="interactionStatistic" itemscope="" itemtype="https://schema.org/InteractionCounter"><meta itemprop="interactionType" content="https://schema.org/LikeAction"><meta itemprop="userInteractionCount" content="2"></div><div itemprop="interactionStatistic" itemscope="" itemtype="https://schema.org/InteractionCounter"><meta itemprop="interactionType" content="https://schema.org/DislikeAction"><meta itemprop="userInteractionCount" content="0"></div><meta itemprop="keywords" content="Tree,Алгоритм,Дерево"><div class="card border-bottom" style="height: auto !important;"><div class="card-body" style="height: auto !important;"><div class="media mb-2"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/mafulechka/"><div class="m-0 p-0 position-relative"><div class="bg-white avatar-3 rounded-circle m-0 box-shadow"><img loading="lazy" class="avatar-3 rounded-circle m-0" src="./Поиск в ширину (Breadth first search, BFS)_files/avatar.jpg"></div></div></a><div class="media-body"><a href="https://evileg.com/ru/users/mafulechka/" class="mr-2 text-truncate d-block">mafulechka</a><small class="text-muted text-nowrap">16 июля 2019 г. 16:03</small></div></div><h1 itemprop="headline">Поиск в ширину (Breadth first search, BFS)</h1><div><p><a href="https://evileg.com/ru/search/?search=%23Tree">Tree</a>, <a href="https://evileg.com/ru/search/?search=%23%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC">Алгоритм</a>, <a href="https://evileg.com/ru/search/?search=%23%D0%94%D0%B5%D1%80%D0%B5%D0%B2%D0%BE">Дерево</a></p></div><div itemprop="articleBody" class="e-text" style="height: auto !important;"><p><strong>
   Обход
  </strong>
  означает посещение всех узлов графа.
  <strong>
   «Обход в ширину» или «Поиск в ширину» (Breadth first traversal or Breadth first Search)
  </strong>
  - это рекурсивный алгоритм поиска всех вершин графа или древовидной структуры данных. В этой статье вы познакомитесь с примерами алгоритма BFS, псевдокода BFS и кодом алгоритма «поиска в ширину» с реализацией в программах на C ++, C, Java и Python.
 </p><div class="card border mb-3"><div class="card-header">Содержание</div><div class="card-body"><ol class="list-unstyled mb-0"><li><span>1. </span><span><a href="https://evileg.com/ru/post/512/#header_%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_BFS">Алгоритм BFS</a></span></li><li><span>2. </span><span><a href="https://evileg.com/ru/post/512/#header_%D0%9F%D1%80%D0%B8%D0%BC%D0%B5%D1%80_BFS">Пример BFS</a></span></li><li><span>3. </span><span><a href="https://evileg.com/ru/post/512/#header_BFS_%D0%BF%D1%81%D0%B5%D0%B2%D0%B4%D0%BE%D0%BA%D0%BE%D0%B4">BFS псевдокод</a></span></li><li><span>4. </span><span><a href="https://evileg.com/ru/post/512/#header_%D0%9A%D0%BE%D0%B4_BFS">Код BFS</a></span></li><li><span>5. </span><span><a href="https://evileg.com/ru/post/512/#header_BFS_%D0%B2_C">BFS в C</a></span></li><li><span>6. </span><span><a href="https://evileg.com/ru/post/512/#header_BFS_%D0%B2_C++">BFS в C++</a></span></li><li><span>7. </span><span><a href="https://evileg.com/ru/post/512/#header_BFS_Java_%D0%BA%D0%BE%D0%B4_(Java_code)">BFS Java код (Java code)</a></span></li><li><span>8. </span><span><a href="https://evileg.com/ru/post/512/#header_BFS_%D0%B2_Python">BFS в Python</a></span></li></ol></div></div><script async="" src="./Поиск в ширину (Breadth first search, BFS)_files/f(4).txt"></script><!-- Evileg COM Header --><ins class="adsbygoogle" style="display: block; height: 280px;" data-ad-client="ca-pub-8877856398367795" data-ad-slot="4753134862" data-ad-format="auto" data-full-width-responsive="true" data-adsbygoogle-status="done" data-ad-status="unfilled"><ins id="aswift_0_expand" tabindex="0" title="Advertisement" aria-label="Advertisement" style="border: none; height: 280px; width: 793px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;"><ins id="aswift_0_anchor" style="border: none; height: 280px; width: 793px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block; overflow: visible;"><iframe id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;border:0;width:793px;height:280px" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="793" height="280" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="./Поиск в ширину (Breadth first search, BFS)_files/ads.html" data-google-container-id="a!1" data-google-query-id="CJ_qxrLz-fYCFVX_sgodzHkD8g" data-load-complete="true"></iframe></ins></ins></ins><script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script><p><span class="small">ADS</span></p><h2><a class="anchor" id="header_Алгоритм_BFS"></a>
  Алгоритм BFS
 </h2><p>
  Стандартная реализация ВFS помещает каждую вершину графа в одну из двух категорий:
 </p><ol><li>
   Посещенные.
  </li><li>
   Не посещенные.
  </li></ol><p><em>
   Цель алгоритма
  </em>
  - пометить каждую вершину, как посещенную, избегая циклов.
 </p><p>
  Алгоритм работает следующим образом:
 </p><ol><li>
   Начните с размещения любой вершины графа в конце очереди.
  </li><li>
   Возьмите передний элемент очереди и добавьте его в список посещенных.
  </li><li>
   Создайте список смежных узлов этой вершины. Добавьте те, которых нет в списке посещенных, в конец очереди.
  </li><li>
   Продолжайте повторять шаги 2 и 3, пока очередь не опустеет.
  </li></ol><p>
  Граф может иметь две разные несвязанные части, поэтому, чтобы убедиться, что мы покрываем каждую вершину, мы также можем запустить алгоритм BFS на каждом узле.
 </p><h2><a class="anchor" id="header_Пример_BFS"></a>
  Пример BFS
 </h2><p>
  Давайте посмотрим, как алгоритм «поиска в ширину» работает на примере. Мы используем неориентированный граф с 5 вершинами.
 </p><p><a href="https://evileg.com/users/mafulechka/albums/photo/758/"><img alt="" class="img-fluid" loading="lazy" src="./Поиск в ширину (Breadth first search, BFS)_files/photo_RJfYSTQ.jpg"></a></p><p>
  Мы начнем с вершины 0, алгоритм BFS начинается с помещения его в список посещенных и размещения всех смежных вершин в стеке.
 </p><p><a href="https://evileg.com/users/mafulechka/albums/photo/759/"><img alt="" class="img-fluid" loading="lazy" src="./Поиск в ширину (Breadth first search, BFS)_files/photo_KW8Kfe5.jpg"></a></p><p>
  Затем мы посещаем элемент в начале очереди, то есть 1, и переходим к соседним узлам. Так как 0 уже был посещен, мы посещаем 2.
 </p><p><a href="https://evileg.com/users/mafulechka/albums/photo/760/"><img alt="" class="img-fluid" loading="lazy" src="./Поиск в ширину (Breadth first search, BFS)_files/photo_vDoSuVQ.jpg"></a></p><p>
  У вершины 2 есть соседняя не посещенная вершина 4, поэтому мы добавляем ее в конец очереди и посещаем 3, которая находится в начале очереди.
 </p><p><a href="https://evileg.com/users/mafulechka/albums/photo/761/"><img alt="" class="img-fluid" loading="lazy" src="./Поиск в ширину (Breadth first search, BFS)_files/photo_t3r5vs8.jpg"></a></p><p><a href="https://evileg.com/users/mafulechka/albums/photo/762/"><img alt="" class="img-fluid" loading="lazy" src="./Поиск в ширину (Breadth first search, BFS)_files/photo_xKZ9aUO.jpg"></a></p><p>
  В очереди остается только 4, поскольку единственный соседний узел с 3, то есть 0, уже посещен. Мы посещаем вершину 4.
 </p><p><a href="https://evileg.com/users/mafulechka/albums/photo/763/"><img alt="" class="img-fluid" loading="lazy" src="./Поиск в ширину (Breadth first search, BFS)_files/photo_XsnjTzJ.jpg"></a></p><p>
  Поскольку очередь пуста, мы завершили обход в ширину графика.
 </p><h2><a class="anchor" id="header_BFS_псевдокод"></a>
  BFS псевдокод
 </h2><pre><pre class="lang-cpp prettyprint linenums prettyprinted" style=""><ol class="linenums"><li class="L0"><span class="pln">create a </span><span class="typ">queue</span><span class="pln"> Q </span></li><li class="L1"><span class="pln">mark v as visited and put v into Q </span></li><li class="L2"><span class="kwd">while</span><span class="pln"> Q is non</span><span class="pun">-</span><span class="pln">empty </span></li><li class="L3"><span class="pln">    remove the head u of Q </span></li><li class="L4"><span class="pln">    mark and enqueue all </span><span class="pun">(</span><span class="pln">unvisited</span><span class="pun">)</span><span class="pln"> neighbours of u</span></li></ol></pre></pre><h2><a class="anchor" id="header_Код_BFS"></a>
  Код BFS
 </h2><p>
  Код для алгоритма «поиска в ширину» с примером показан ниже. Код был упрощен, поэтому мы можем сосредоточиться на алгоритме, а не на других деталях.
 </p><h2><a class="anchor" id="header_BFS_в_C"></a>
  BFS в C
 </h2><pre><pre class="lang-cpp prettyprint linenums prettyprinted" style=""><ol class="linenums"><li class="L0"><span class="com">#include</span><span class="pln"> </span><span class="str">&lt;stdio.h&gt;</span></li><li class="L1"><span class="com">#include</span><span class="pln"> </span><span class="str">&lt;stdlib.h&gt;</span></li><li class="L2"><span class="com">#define</span><span class="pln"> SIZE </span><span class="lit">40</span></li><li class="L3"><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln">    </span><span class="typ">int</span><span class="pln"> items</span><span class="pun">[</span><span class="pln">SIZE</span><span class="pun">];</span></li><li class="L5"><span class="pln">    </span><span class="typ">int</span><span class="pln"> front</span><span class="pun">;</span></li><li class="L6"><span class="pln">    </span><span class="typ">int</span><span class="pln"> rear</span><span class="pun">;</span></li><li class="L7"><span class="pun">};</span></li><li class="L8"><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> createQueue</span><span class="pun">();</span></li><li class="L9"><span class="kwd">void</span><span class="pln"> enqueue</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pun">);</span></li><li class="L0"><span class="typ">int</span><span class="pln"> </span><span class="typ">dequeue</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q</span><span class="pun">);</span></li><li class="L1"><span class="kwd">void</span><span class="pln"> display</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q</span><span class="pun">);</span></li><li class="L2"><span class="typ">int</span><span class="pln"> isEmpty</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q</span><span class="pun">);</span></li><li class="L3"><span class="kwd">void</span><span class="pln"> printQueue</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q</span><span class="pun">);</span></li><li class="L4"><span class="kwd">struct</span><span class="pln"> node</span></li><li class="L5"><span class="pun">{</span></li><li class="L6"><span class="pln">    </span><span class="typ">int</span><span class="pln"> vertex</span><span class="pun">;</span></li><li class="L7"><span class="pln">    </span><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">*</span><span class="pln"> next</span><span class="pun">;</span></li><li class="L8"><span class="pun">};</span></li><li class="L9"><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">*</span><span class="pln"> createNode</span><span class="pun">(</span><span class="typ">int</span><span class="pun">);</span></li><li class="L0"><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span></li><li class="L1"><span class="pun">{</span></li><li class="L2"><span class="pln">    </span><span class="typ">int</span><span class="pln"> numVertices</span><span class="pun">;</span></li><li class="L3"><span class="pln">    </span><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">**</span><span class="pln"> adjLists</span><span class="pun">;</span></li><li class="L4"><span class="pln">    </span><span class="typ">int</span><span class="pun">*</span><span class="pln"> visited</span><span class="pun">;</span></li><li class="L5"><span class="pun">};</span></li><li class="L6"><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> createGraph</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> vertices</span><span class="pun">);</span></li><li class="L7"><span class="kwd">void</span><span class="pln"> addEdge</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> graph</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> src</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> dest</span><span class="pun">);</span></li><li class="L8"><span class="kwd">void</span><span class="pln"> printGraph</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> graph</span><span class="pun">);</span></li><li class="L9"><span class="kwd">void</span><span class="pln"> bfs</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> graph</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> startVertex</span><span class="pun">);</span></li><li class="L0"><span class="typ">int</span><span class="pln"> main</span><span class="pun">()</span></li><li class="L1"><span class="pun">{</span></li><li class="L2"><span class="pln">    </span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> graph </span><span class="pun">=</span><span class="pln"> createGraph</span><span class="pun">(</span><span class="lit">6</span><span class="pun">);</span></li><li class="L3"><span class="pln">    addEdge</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">);</span></li><li class="L4"><span class="pln">    addEdge</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">);</span></li><li class="L5"><span class="pln">    addEdge</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">);</span></li><li class="L6"><span class="pln">    addEdge</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="lit">4</span><span class="pun">);</span></li><li class="L7"><span class="pln">    addEdge</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="lit">3</span><span class="pun">);</span></li><li class="L8"><span class="pln">    addEdge</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="lit">4</span><span class="pun">);</span></li><li class="L9"><span class="pln">    addEdge</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">3</span><span class="pun">,</span><span class="pln"> </span><span class="lit">4</span><span class="pun">);</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">    bfs</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">);</span></li><li class="L2"><span class="pln">&nbsp;</span></li><li class="L3"><span class="pln">    </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L4"><span class="pun">}</span></li><li class="L5"><span class="kwd">void</span><span class="pln"> bfs</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> graph</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> startVertex</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln">    </span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q </span><span class="pun">=</span><span class="pln"> createQueue</span><span class="pun">();</span></li><li class="L7"><span class="pln">&nbsp;</span></li><li class="L8"><span class="pln">    graph</span><span class="pun">-&gt;</span><span class="pln">visited</span><span class="pun">[</span><span class="pln">startVertex</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L9"><span class="pln">    enqueue</span><span class="pun">(</span><span class="pln">q</span><span class="pun">,</span><span class="pln"> startVertex</span><span class="pun">);</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">    </span><span class="kwd">while</span><span class="pun">(!</span><span class="pln">isEmpty</span><span class="pun">(</span><span class="pln">q</span><span class="pun">)){</span></li><li class="L2"><span class="pln">        printQueue</span><span class="pun">(</span><span class="pln">q</span><span class="pun">);</span></li><li class="L3"><span class="pln">        </span><span class="typ">int</span><span class="pln"> currentVertex </span><span class="pun">=</span><span class="pln"> </span><span class="typ">dequeue</span><span class="pun">(</span><span class="pln">q</span><span class="pun">);</span></li><li class="L4"><span class="pln">        printf</span><span class="pun">(</span><span class="str">"Visited %d\n"</span><span class="pun">,</span><span class="pln"> currentVertex</span><span class="pun">);</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="pln">       </span><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">*</span><span class="pln"> temp </span><span class="pun">=</span><span class="pln"> graph</span><span class="pun">-&gt;</span><span class="pln">adjLists</span><span class="pun">[</span><span class="pln">currentVertex</span><span class="pun">];</span></li><li class="L7"><span class="pln">&nbsp;</span></li><li class="L8"><span class="pln">       </span><span class="kwd">while</span><span class="pun">(</span><span class="pln">temp</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln">            </span><span class="typ">int</span><span class="pln"> adjVertex </span><span class="pun">=</span><span class="pln"> temp</span><span class="pun">-&gt;</span><span class="pln">vertex</span><span class="pun">;</span></li><li class="L0"><span class="pln">            </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">-&gt;</span><span class="pln">visited</span><span class="pun">[</span><span class="pln">adjVertex</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">){</span></li><li class="L1"><span class="pln">                graph</span><span class="pun">-&gt;</span><span class="pln">visited</span><span class="pun">[</span><span class="pln">adjVertex</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L2"><span class="pln">                enqueue</span><span class="pun">(</span><span class="pln">q</span><span class="pun">,</span><span class="pln"> adjVertex</span><span class="pun">);</span></li><li class="L3"><span class="pln">            </span><span class="pun">}</span></li><li class="L4"><span class="pln">            temp </span><span class="pun">=</span><span class="pln"> temp</span><span class="pun">-&gt;</span><span class="pln">next</span><span class="pun">;</span></li><li class="L5"><span class="pln">       </span><span class="pun">}</span></li><li class="L6"><span class="pln">    </span><span class="pun">}</span></li><li class="L7"><span class="pun">}</span></li><li class="L8"><span class="pln">&nbsp;</span></li><li class="L9"><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">*</span><span class="pln"> createNode</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> v</span><span class="pun">)</span></li><li class="L0"><span class="pun">{</span></li><li class="L1"><span class="pln">    </span><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">*</span><span class="pln"> newNode </span><span class="pun">=</span><span class="pln"> malloc</span><span class="pun">(</span><span class="kwd">sizeof</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">));</span></li><li class="L2"><span class="pln">    newNode</span><span class="pun">-&gt;</span><span class="pln">vertex </span><span class="pun">=</span><span class="pln"> v</span><span class="pun">;</span></li><li class="L3"><span class="pln">    newNode</span><span class="pun">-&gt;</span><span class="pln">next </span><span class="pun">=</span><span class="pln"> NULL</span><span class="pun">;</span></li><li class="L4"><span class="pln">    </span><span class="kwd">return</span><span class="pln"> newNode</span><span class="pun">;</span></li><li class="L5"><span class="pun">}</span></li><li class="L6"><span class="pln">&nbsp;</span></li><li class="L7"><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> createGraph</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> vertices</span><span class="pun">)</span></li><li class="L8"><span class="pun">{</span></li><li class="L9"><span class="pln">    </span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> graph </span><span class="pun">=</span><span class="pln"> malloc</span><span class="pun">(</span><span class="kwd">sizeof</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">));</span></li><li class="L0"><span class="pln">    graph</span><span class="pun">-&gt;</span><span class="pln">numVertices </span><span class="pun">=</span><span class="pln"> vertices</span><span class="pun">;</span></li><li class="L1"><span class="pln">&nbsp;</span></li><li class="L2"><span class="pln">    graph</span><span class="pun">-&gt;</span><span class="pln">adjLists </span><span class="pun">=</span><span class="pln"> malloc</span><span class="pun">(</span><span class="pln">vertices </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">sizeof</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">*));</span></li><li class="L3"><span class="pln">    graph</span><span class="pun">-&gt;</span><span class="pln">visited </span><span class="pun">=</span><span class="pln"> malloc</span><span class="pun">(</span><span class="pln">vertices </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">sizeof</span><span class="pun">(</span><span class="typ">int</span><span class="pun">));</span></li><li class="L4"><span class="pln">&nbsp;</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="pln">    </span><span class="typ">int</span><span class="pln"> i</span><span class="pun">;</span></li><li class="L7"><span class="pln">    </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln">i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> vertices</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln">        graph</span><span class="pun">-&gt;</span><span class="pln">adjLists</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> NULL</span><span class="pun">;</span></li><li class="L9"><span class="pln">        graph</span><span class="pun">-&gt;</span><span class="pln">visited</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L0"><span class="pln">    </span><span class="pun">}</span></li><li class="L1"><span class="pln">&nbsp;</span></li><li class="L2"><span class="pln">    </span><span class="kwd">return</span><span class="pln"> graph</span><span class="pun">;</span></li><li class="L3"><span class="pun">}</span></li><li class="L4"><span class="pln">&nbsp;</span></li><li class="L5"><span class="kwd">void</span><span class="pln"> addEdge</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">*</span><span class="pln"> graph</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> src</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> dest</span><span class="pun">)</span></li><li class="L6"><span class="pun">{</span></li><li class="L7"><span class="pln">    </span><span class="com">// Add edge from src to dest</span></li><li class="L8"><span class="pln">    </span><span class="kwd">struct</span><span class="pln"> node</span><span class="pun">*</span><span class="pln"> newNode </span><span class="pun">=</span><span class="pln"> createNode</span><span class="pun">(</span><span class="pln">dest</span><span class="pun">);</span></li><li class="L9"><span class="pln">    newNode</span><span class="pun">-&gt;</span><span class="pln">next </span><span class="pun">=</span><span class="pln"> graph</span><span class="pun">-&gt;</span><span class="pln">adjLists</span><span class="pun">[</span><span class="pln">src</span><span class="pun">];</span></li><li class="L0"><span class="pln">    graph</span><span class="pun">-&gt;</span><span class="pln">adjLists</span><span class="pun">[</span><span class="pln">src</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> newNode</span><span class="pun">;</span></li><li class="L1"><span class="pln">&nbsp;</span></li><li class="L2"><span class="pln">    </span><span class="com">// Add edge from dest to src</span></li><li class="L3"><span class="pln">    newNode </span><span class="pun">=</span><span class="pln"> createNode</span><span class="pun">(</span><span class="pln">src</span><span class="pun">);</span></li><li class="L4"><span class="pln">    newNode</span><span class="pun">-&gt;</span><span class="pln">next </span><span class="pun">=</span><span class="pln"> graph</span><span class="pun">-&gt;</span><span class="pln">adjLists</span><span class="pun">[</span><span class="pln">dest</span><span class="pun">];</span></li><li class="L5"><span class="pln">    graph</span><span class="pun">-&gt;</span><span class="pln">adjLists</span><span class="pun">[</span><span class="pln">dest</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> newNode</span><span class="pun">;</span></li><li class="L6"><span class="pun">}</span></li><li class="L7"><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> createQueue</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln">    </span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q </span><span class="pun">=</span><span class="pln"> malloc</span><span class="pun">(</span><span class="kwd">sizeof</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">));</span></li><li class="L9"><span class="pln">    q</span><span class="pun">-&gt;</span><span class="pln">front </span><span class="pun">=</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">;</span></li><li class="L0"><span class="pln">    q</span><span class="pun">-&gt;</span><span class="pln">rear </span><span class="pun">=</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">;</span></li><li class="L1"><span class="pln">    </span><span class="kwd">return</span><span class="pln"> q</span><span class="pun">;</span></li><li class="L2"><span class="pun">}</span></li><li class="L3"><span class="typ">int</span><span class="pln"> isEmpty</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln">    </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">q</span><span class="pun">-&gt;</span><span class="pln">rear </span><span class="pun">==</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">)</span><span class="pln"> </span></li><li class="L5"><span class="pln">        </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L6"><span class="pln">    </span><span class="kwd">else</span><span class="pln"> </span></li><li class="L7"><span class="pln">        </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L8"><span class="pun">}</span></li><li class="L9"><span class="kwd">void</span><span class="pln"> enqueue</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> value</span><span class="pun">){</span></li><li class="L0"><span class="pln">    </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">q</span><span class="pun">-&gt;</span><span class="pln">rear </span><span class="pun">==</span><span class="pln"> SIZE</span><span class="pun">-</span><span class="lit">1</span><span class="pun">)</span></li><li class="L1"><span class="pln">        printf</span><span class="pun">(</span><span class="str">"\nQueue is Full!!"</span><span class="pun">);</span></li><li class="L2"><span class="pln">    </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln">        </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">q</span><span class="pun">-&gt;</span><span class="pln">front </span><span class="pun">==</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">)</span></li><li class="L4"><span class="pln">            q</span><span class="pun">-&gt;</span><span class="pln">front </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L5"><span class="pln">        q</span><span class="pun">-&gt;</span><span class="pln">rear</span><span class="pun">++;</span></li><li class="L6"><span class="pln">        q</span><span class="pun">-&gt;</span><span class="pln">items</span><span class="pun">[</span><span class="pln">q</span><span class="pun">-&gt;</span><span class="pln">rear</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> value</span><span class="pun">;</span></li><li class="L7"><span class="pln">    </span><span class="pun">}</span></li><li class="L8"><span class="pun">}</span></li><li class="L9"><span class="typ">int</span><span class="pln"> </span><span class="typ">dequeue</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">*</span><span class="pln"> q</span><span class="pun">){</span></li><li class="L0"><span class="pln">    </span><span class="typ">int</span><span class="pln"> item</span><span class="pun">;</span></li><li class="L1"><span class="pln">    </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">isEmpty</span><span class="pun">(</span><span class="pln">q</span><span class="pun">)){</span></li><li class="L2"><span class="pln">        printf</span><span class="pun">(</span><span class="str">"Queue is empty"</span><span class="pun">);</span></li><li class="L3"><span class="pln">        item </span><span class="pun">=</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">;</span></li><li class="L4"><span class="pln">    </span><span class="pun">}</span></li><li class="L5"><span class="pln">    </span><span class="kwd">else</span><span class="pun">{</span></li><li class="L6"><span class="pln">        item </span><span class="pun">=</span><span class="pln"> q</span><span class="pun">-&gt;</span><span class="pln">items</span><span class="pun">[</span><span class="pln">q</span><span class="pun">-&gt;</span><span class="pln">front</span><span class="pun">];</span></li><li class="L7"><span class="pln">        q</span><span class="pun">-&gt;</span><span class="pln">front</span><span class="pun">++;</span></li><li class="L8"><span class="pln">        </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">q</span><span class="pun">-&gt;</span><span class="pln">front </span><span class="pun">&gt;</span><span class="pln"> q</span><span class="pun">-&gt;</span><span class="pln">rear</span><span class="pun">){</span></li><li class="L9"><span class="pln">            printf</span><span class="pun">(</span><span class="str">"Resetting queue"</span><span class="pun">);</span></li><li class="L0"><span class="pln">            q</span><span class="pun">-&gt;</span><span class="pln">front </span><span class="pun">=</span><span class="pln"> q</span><span class="pun">-&gt;</span><span class="pln">rear </span><span class="pun">=</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">;</span></li><li class="L1"><span class="pln">        </span><span class="pun">}</span></li><li class="L2"><span class="pln">    </span><span class="pun">}</span></li><li class="L3"><span class="pln">    </span><span class="kwd">return</span><span class="pln"> item</span><span class="pun">;</span></li><li class="L4"><span class="pun">}</span></li><li class="L5"><span class="kwd">void</span><span class="pln"> printQueue</span><span class="pun">(</span><span class="kwd">struct</span><span class="pln"> </span><span class="typ">queue</span><span class="pln"> </span><span class="pun">*</span><span class="pln">q</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln">    </span><span class="typ">int</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> q</span><span class="pun">-&gt;</span><span class="pln">front</span><span class="pun">;</span></li><li class="L7"><span class="pln">    </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">isEmpty</span><span class="pun">(</span><span class="pln">q</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln">        printf</span><span class="pun">(</span><span class="str">"Queue is empty"</span><span class="pun">);</span></li><li class="L9"><span class="pln">    </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln">        printf</span><span class="pun">(</span><span class="str">"\nQueue contains \n"</span><span class="pun">);</span></li><li class="L1"><span class="pln">        </span><span class="kwd">for</span><span class="pun">(</span><span class="pln">i </span><span class="pun">=</span><span class="pln"> q</span><span class="pun">-&gt;</span><span class="pln">front</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> q</span><span class="pun">-&gt;</span><span class="pln">rear </span><span class="pun">+</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln">                printf</span><span class="pun">(</span><span class="str">"%d "</span><span class="pun">,</span><span class="pln"> q</span><span class="pun">-&gt;</span><span class="pln">items</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]);</span></li><li class="L3"><span class="pln">        </span><span class="pun">}</span></li><li class="L4"><span class="pln">    </span><span class="pun">}</span><span class="pln">    </span></li><li class="L5"><span class="pun">}</span></li></ol></pre></pre><h2><a class="anchor" id="header_BFS_в_C++"></a>
  BFS в C++
 </h2><pre><pre class="lang-cpp prettyprint linenums prettyprinted" style=""><ol class="linenums"><li class="L0"><span class="com">#include</span><span class="pln"> </span><span class="str">&lt;iostream&gt;</span></li><li class="L1"><span class="com">#include</span><span class="pln"> </span><span class="str">&lt;list&gt;</span></li><li class="L2"><span class="pln">&nbsp;</span></li><li class="L3"><span class="kwd">using</span><span class="pln"> </span><span class="kwd">namespace</span><span class="pln"> std</span><span class="pun">;</span></li><li class="L4"><span class="pln">&nbsp;</span></li><li class="L5"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Graph</span></li><li class="L6"><span class="pun">{</span></li><li class="L7"><span class="pln">    </span><span class="typ">int</span><span class="pln"> numVertices</span><span class="pun">;</span></li><li class="L8"><span class="pln">    </span><span class="typ">list</span><span class="pln"> </span><span class="pun">*</span><span class="pln">adjLists</span><span class="pun">;</span></li><li class="L9"><span class="pln">    </span><span class="kwd">bool</span><span class="pun">*</span><span class="pln"> visited</span><span class="pun">;</span></li><li class="L0"><span class="kwd">public</span><span class="pun">:</span></li><li class="L1"><span class="pln">    </span><span class="typ">Graph</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> vertices</span><span class="pun">);</span><span class="pln">  </span></li><li class="L2"><span class="pln">    </span><span class="kwd">void</span><span class="pln"> addEdge</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> src</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> dest</span><span class="pun">);</span><span class="pln"> </span></li><li class="L3"><span class="pln">    </span><span class="kwd">void</span><span class="pln"> BFS</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> startVertex</span><span class="pun">);</span></li><li class="L4"><span class="pun">};</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="typ">Graph</span><span class="pun">::</span><span class="typ">Graph</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> vertices</span><span class="pun">)</span></li><li class="L7"><span class="pun">{</span></li><li class="L8"><span class="pln">    numVertices </span><span class="pun">=</span><span class="pln"> vertices</span><span class="pun">;</span></li><li class="L9"><span class="pln">    adjLists </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">list</span><span class="pun">[</span><span class="pln">vertices</span><span class="pun">];</span></li><li class="L0"><span class="pun">}</span></li><li class="L1"><span class="pln">&nbsp;</span></li><li class="L2"><span class="kwd">void</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">::</span><span class="pln">addEdge</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> src</span><span class="pun">,</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> dest</span><span class="pun">)</span></li><li class="L3"><span class="pun">{</span></li><li class="L4"><span class="pln">    adjLists</span><span class="pun">[</span><span class="pln">src</span><span class="pun">].</span><span class="pln">push_back</span><span class="pun">(</span><span class="pln">dest</span><span class="pun">);</span></li><li class="L5"><span class="pln">    adjLists</span><span class="pun">[</span><span class="pln">dest</span><span class="pun">].</span><span class="pln">push_back</span><span class="pun">(</span><span class="pln">src</span><span class="pun">);</span></li><li class="L6"><span class="pun">}</span></li><li class="L7"><span class="pln">&nbsp;</span></li><li class="L8"><span class="kwd">void</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">::</span><span class="pln">BFS</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> startVertex</span><span class="pun">)</span></li><li class="L9"><span class="pun">{</span></li><li class="L0"><span class="pln">    visited </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="kwd">bool</span><span class="pun">[</span><span class="pln">numVertices</span><span class="pun">];</span></li><li class="L1"><span class="pln">    </span><span class="kwd">for</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> numVertices</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span></li><li class="L2"><span class="pln">        visited</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span></li><li class="L3"><span class="pln">&nbsp;</span></li><li class="L4"><span class="pln">    </span><span class="typ">list</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">;</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="pln">    visited</span><span class="pun">[</span><span class="pln">startVertex</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">;</span></li><li class="L7"><span class="pln">    </span><span class="typ">queue</span><span class="pun">.</span><span class="pln">push_back</span><span class="pun">(</span><span class="pln">startVertex</span><span class="pun">);</span></li><li class="L8"><span class="pln">&nbsp;</span></li><li class="L9"><span class="pln">    </span><span class="typ">list</span><span class="pun">::</span><span class="typ">iterator</span><span class="pln"> i</span><span class="pun">;</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">    </span><span class="kwd">while</span><span class="pun">(!</span><span class="typ">queue</span><span class="pun">.</span><span class="pln">empty</span><span class="pun">())</span></li><li class="L2"><span class="pln">    </span><span class="pun">{</span></li><li class="L3"><span class="pln">        </span><span class="typ">int</span><span class="pln"> currVertex </span><span class="pun">=</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">.</span><span class="pln">front</span><span class="pun">();</span></li><li class="L4"><span class="pln">        cout </span><span class="pun">&lt;&lt;</span><span class="pln"> </span><span class="str">"Visited "</span><span class="pln"> </span><span class="pun">&lt;&lt;</span><span class="pln"> currVertex </span><span class="pun">&lt;&lt;</span><span class="pln"> </span><span class="str">" "</span><span class="pun">;</span></li><li class="L5"><span class="pln">        </span><span class="typ">queue</span><span class="pun">.</span><span class="pln">pop_front</span><span class="pun">();</span></li><li class="L6"><span class="pln">&nbsp;</span></li><li class="L7"><span class="pln">        </span><span class="kwd">for</span><span class="pun">(</span><span class="pln">i </span><span class="pun">=</span><span class="pln"> adjLists</span><span class="pun">[</span><span class="pln">currVertex</span><span class="pun">].</span><span class="pln">begin</span><span class="pun">();</span><span class="pln"> i </span><span class="pun">!=</span><span class="pln"> adjLists</span><span class="pun">[</span><span class="pln">currVertex</span><span class="pun">].</span><span class="pln">end</span><span class="pun">();</span><span class="pln"> </span><span class="pun">++</span><span class="pln">i</span><span class="pun">)</span></li><li class="L8"><span class="pln">        </span><span class="pun">{</span></li><li class="L9"><span class="pln">            </span><span class="typ">int</span><span class="pln"> adjVertex </span><span class="pun">=</span><span class="pln"> </span><span class="pun">*</span><span class="pln">i</span><span class="pun">;</span></li><li class="L0"><span class="pln">            </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">visited</span><span class="pun">[</span><span class="pln">adjVertex</span><span class="pun">])</span></li><li class="L1"><span class="pln">            </span><span class="pun">{</span></li><li class="L2"><span class="pln">                visited</span><span class="pun">[</span><span class="pln">adjVertex</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">;</span></li><li class="L3"><span class="pln">                </span><span class="typ">queue</span><span class="pun">.</span><span class="pln">push_back</span><span class="pun">(</span><span class="pln">adjVertex</span><span class="pun">);</span></li><li class="L4"><span class="pln">            </span><span class="pun">}</span></li><li class="L5"><span class="pln">        </span><span class="pun">}</span></li><li class="L6"><span class="pln">    </span><span class="pun">}</span></li><li class="L7"><span class="pun">}</span></li><li class="L8"><span class="pln">&nbsp;</span></li><li class="L9"><span class="typ">int</span><span class="pln"> main</span><span class="pun">()</span></li><li class="L0"><span class="pun">{</span></li><li class="L1"><span class="pln">    </span><span class="typ">Graph</span><span class="pln"> g</span><span class="pun">(</span><span class="lit">4</span><span class="pun">);</span></li><li class="L2"><span class="pln">    g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">);</span></li><li class="L3"><span class="pln">    g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">);</span></li><li class="L4"><span class="pln">    g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">);</span></li><li class="L5"><span class="pln">    g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">);</span></li><li class="L6"><span class="pln">    g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="lit">3</span><span class="pun">);</span></li><li class="L7"><span class="pln">    g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">3</span><span class="pun">,</span><span class="pln"> </span><span class="lit">3</span><span class="pun">);</span></li><li class="L8"><span class="pln">    g</span><span class="pun">.</span><span class="pln">BFS</span><span class="pun">(</span><span class="lit">2</span><span class="pun">);</span></li><li class="L9"><span class="pln">&nbsp;</span></li><li class="L0"><span class="pln">    </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L1"><span class="pun">}</span></li></ol></pre></pre><h2><a class="anchor" id="header_BFS_Java_код_(Java_code)"></a>
  BFS Java код (Java code)
 </h2><pre><pre class="lang-cpp prettyprint linenums prettyprinted" style=""><ol class="linenums"><li class="L0"><span class="kwd">import</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">io</span><span class="pun">.*;</span></li><li class="L1"><span class="kwd">import</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">util</span><span class="pun">.*;</span></li><li class="L2"><span class="pln">&nbsp;</span></li><li class="L3"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Graph</span></li><li class="L4"><span class="pun">{</span></li><li class="L5"><span class="pln">    </span><span class="kwd">private</span><span class="pln"> </span><span class="typ">int</span><span class="pln"> numVertices</span><span class="pun">;</span></li><li class="L6"><span class="pln">    </span><span class="kwd">private</span><span class="pln"> </span><span class="typ">LinkedList</span><span class="pun">&lt;</span><span class="typ">Integer</span><span class="pun">&gt;</span><span class="pln"> adjLists</span><span class="pun">[];</span></li><li class="L7"><span class="pln">    </span><span class="kwd">private</span><span class="pln"> boolean visited</span><span class="pun">[];</span></li><li class="L8"><span class="pln">&nbsp;</span></li><li class="L9"><span class="pln">    </span><span class="typ">Graph</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> v</span><span class="pun">)</span></li><li class="L0"><span class="pln">    </span><span class="pun">{</span></li><li class="L1"><span class="pln">        numVertices </span><span class="pun">=</span><span class="pln"> v</span><span class="pun">;</span></li><li class="L2"><span class="pln">        visited </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> boolean</span><span class="pun">[</span><span class="pln">numVertices</span><span class="pun">];</span></li><li class="L3"><span class="pln">        adjLists </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">LinkedList</span><span class="pun">[</span><span class="pln">numVertices</span><span class="pun">];</span></li><li class="L4"><span class="pln">        </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="typ">int</span><span class="pln"> i</span><span class="pun">=</span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i i </span><span class="pun">=</span><span class="pln"> adjLists</span><span class="pun">[</span><span class="pln">currVertex</span><span class="pun">].</span><span class="pln">listIterator</span><span class="pun">();</span></li><li class="L5"><span class="pln">            </span><span class="kwd">while</span><span class="pln"> </span><span class="pun">(</span><span class="pln">i</span><span class="pun">.</span><span class="pln">hasNext</span><span class="pun">())</span></li><li class="L6"><span class="pln">            </span><span class="pun">{</span></li><li class="L7"><span class="pln">                </span><span class="typ">int</span><span class="pln"> adjVertex </span><span class="pun">=</span><span class="pln"> i</span><span class="pun">.</span><span class="pln">next</span><span class="pun">();</span></li><li class="L8"><span class="pln">                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">visited</span><span class="pun">[</span><span class="pln">adjVertex</span><span class="pun">])</span></li><li class="L9"><span class="pln">                </span><span class="pun">{</span></li><li class="L0"><span class="pln">                    visited</span><span class="pun">[</span><span class="pln">adjVertex</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">;</span></li><li class="L1"><span class="pln">                    </span><span class="typ">queue</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">adjVertex</span><span class="pun">);</span></li><li class="L2"><span class="pln">                </span><span class="pun">}</span></li><li class="L3"><span class="pln">            </span><span class="pun">}</span></li><li class="L4"><span class="pln">        </span><span class="pun">}</span></li><li class="L5"><span class="pln">    </span><span class="pun">}</span></li><li class="L6"><span class="pln">&nbsp;</span></li><li class="L7"><span class="pln">    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> main</span><span class="pun">(</span><span class="typ">String</span><span class="pln"> args</span><span class="pun">[])</span></li><li class="L8"><span class="pln">    </span><span class="pun">{</span></li><li class="L9"><span class="pln">        </span><span class="typ">Graph</span><span class="pln"> g </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Graph</span><span class="pun">(</span><span class="lit">4</span><span class="pun">);</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">        g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">);</span></li><li class="L2"><span class="pln">        g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">);</span></li><li class="L3"><span class="pln">        g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">);</span></li><li class="L4"><span class="pln">        g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">);</span></li><li class="L5"><span class="pln">        g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="lit">3</span><span class="pun">);</span></li><li class="L6"><span class="pln">        g</span><span class="pun">.</span><span class="pln">addEdge</span><span class="pun">(</span><span class="lit">3</span><span class="pun">,</span><span class="pln"> </span><span class="lit">3</span><span class="pun">);</span></li><li class="L7"><span class="pln">&nbsp;</span></li><li class="L8"><span class="pln">        </span><span class="typ">System</span><span class="pun">.</span><span class="pln">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">"Following is Breadth First Traversal "</span><span class="pun">+</span></li><li class="L9"><span class="pln">                           </span><span class="str">"(starting from vertex 2)"</span><span class="pun">);</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">        g</span><span class="pun">.</span><span class="pln">BFS</span><span class="pun">(</span><span class="lit">2</span><span class="pun">);</span></li><li class="L2"><span class="pln">    </span><span class="pun">}</span></li><li class="L3"><span class="pun">}</span></li></ol></pre></pre><h2><a class="anchor" id="header_BFS_в_Python"></a>
  BFS в Python
 </h2><pre><pre class="lang-cpp prettyprint linenums prettyprinted" style=""><ol class="linenums"><li class="L0"><span class="kwd">import</span><span class="pln"> collections</span></li><li class="L1"><span class="pln">def bfs</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> root</span><span class="pun">):</span><span class="pln"> </span></li><li class="L2"><span class="pln">    visited</span><span class="pun">,</span><span class="pln"> </span><span class="typ">queue</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="typ">set</span><span class="pun">(),</span><span class="pln"> collections</span><span class="pun">.</span><span class="pln">deque</span><span class="pun">([</span><span class="pln">root</span><span class="pun">])</span></li><li class="L3"><span class="pln">    visited</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">root</span><span class="pun">)</span></li><li class="L4"><span class="pln">    </span><span class="kwd">while</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">:</span><span class="pln"> </span></li><li class="L5"><span class="pln">        vertex </span><span class="pun">=</span><span class="pln"> </span><span class="typ">queue</span><span class="pun">.</span><span class="pln">popleft</span><span class="pun">()</span></li><li class="L6"><span class="pln">        </span><span class="kwd">for</span><span class="pln"> neighbour in graph</span><span class="pun">[</span><span class="pln">vertex</span><span class="pun">]:</span><span class="pln"> </span></li><li class="L7"><span class="pln">            </span><span class="kwd">if</span><span class="pln"> neighbour not in visited</span><span class="pun">:</span><span class="pln"> </span></li><li class="L8"><span class="pln">                visited</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">neighbour</span><span class="pun">)</span><span class="pln"> </span></li><li class="L9"><span class="pln">                </span><span class="typ">queue</span><span class="pun">.</span><span class="pln">append</span><span class="pun">(</span><span class="pln">neighbour</span><span class="pun">)</span><span class="pln"> </span></li><li class="L0"><span class="kwd">if</span><span class="pln"> __name__ </span><span class="pun">==</span><span class="pln"> </span><span class="str">'__main__'</span><span class="pun">:</span></li><li class="L1"><span class="pln">    graph </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{</span><span class="lit">0</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">],</span><span class="pln"> </span><span class="lit">1</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">2</span><span class="pun">],</span><span class="pln"> </span><span class="lit">2</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">3</span><span class="pun">],</span><span class="pln"> </span><span class="lit">3</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">1</span><span class="pun">,</span><span class="lit">2</span><span class="pun">]}</span><span class="pln"> </span></li><li class="L2"><span class="pln">    breadth_first_search</span><span class="pun">(</span><span class="pln">graph</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span></li></ol></pre></pre></div><a href="https://timeweb.com/ru/?i=27415" rel="nofollow" target="_blank"><div class="media pt-3"><img class="mr-3" src="./Поиск в ширину (Breadth first search, BFS)_files/timeweb-120-90.jpg" alt="Рекомендуем хостинг TIMEWEB"><div class="media-body"><h5 class="mt-0">Рекомендуем хостинг TIMEWEB</h5>
            Стабильный хостинг, на котором располагается социальная сеть EVILEG. Для проектов на Django рекомендуем VDS хостинг.
        </div></div></a></div><div class="card-footer border-top py-3 px-4"><p><strong>Рекомендуемые статьи по этой тематике</strong></p><ul><li><a href="https://evileg.com/ru/post/524/">Алгоритм Прима</a></li><li><a href="https://evileg.com/ru/post/523/">Алгоритм Краскала</a></li><li><a href="https://evileg.com/ru/post/494/">Алгоритм DFS («Depth-first search» или «Поиск в глубину»)</a></li><li><a href="https://evileg.com/ru/post/492/">Граф. Структура данных.</a></li><li><a href="https://evileg.com/ru/post/491/">Двоичное дерево поиска (Binary Search Tree (BST))</a></li><li><a href="https://evileg.com/ru/post/490/">Обход дерева – центрированный (inorder), прямой (preorder) и обратный (postorder) (три основных способа обхода)</a></li></ul><p><strong class="mr-1">По статье задано</strong><a href="https://evileg.com/ru/forum/?search=article:512">0<span class="ml-1">вопрос(ов)</span></a></p><p><strong class="mr-1">Источник: </strong><a href="https://www.programiz.com/dsa/graph-bfs" rel="nofollow" target="_blank">Programiz</a></p><h4><a href="https://evileg.com/ru/post/512/subscribers/">Подписчики</a></h4><div class="switch"><label onclick="Global.nonlogin()" title="Только зарегистрированные пользователи могут подписываться на обновления" class="text-dark"><input type="checkbox" disabled=""><span class="bmd-switch-track"></span>Подписка на обсуждение<span class="badge badge-light ml-2">4</span></label></div><ul class="list-inline mb-0"><li class="list-inline-item"><a class="btn btn-sm btn-dark" href="https://evileg.com/ru/knowledge/algorithms/" title="Перейти к объекту подписки"><span class="mdi mdi-share mdi-18px mdi-0"></span></a></li><li class="list-inline-item"><div class="switch"><label onclick="Global.nonlogin()" title="Только зарегистрированные пользователи могут подписываться на обновления" class="text-dark"><input type="checkbox" disabled=""><span class="bmd-switch-track"></span>Подписка на раздел<span class="badge badge-light ml-2">64</span></label></div></li></ul></div><div class="border-top px-3">
            Поддержать автора
            
            
    
    <a class="btn btn-outline-primary m-2" href="https://evileg.com/ru/post/512/#" data-toggle="modal" data-target="#donateDialog"><small>Donate</small></a><div class="modal fade" id="donateDialog" tabindex="-1" role="dialog" aria-labelledby="donateDialogLabel" aria-hidden="true"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="donateDialogLabel">Платёжная система</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body"><ul class="list-unstyled"><li><a href="https://money.yandex.ru/to/410018355146875" target="_blank" rel="nofollow">Яндекс.Деньги</a></li></ul></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button></div></div></div></div></div><ul class="card-footer act-footer"><li class="act-btn" title="Просмотры"><span class="mdi mdi-eye">49599</span></li><li title="Комментарии"><a class="act-btn mdi mdi-comment" href="https://evileg.com/ru/post/512/#comments">1</a></li><li class="act-btn" onclick="Global.nonlogin()" title="Только зарегистрированные пользователи могут добавлять в избранное"><span data-icon="favorite" class="mdi mdi-star"></span><span data-count="favorite">0</span></li><li class="act-btn" onclick="Global.nonlogin()" title="Только зарегистрированные пользователи могут оценивать"><span data-icon="like" class="mdi mdi-thumb-up"></span><span data-count="like">2</span></li><li class="act-btn" onclick="Global.nonlogin()" title="Только зарегистрированные пользователи могут оценивать"><span data-icon="dislike" class="mdi mdi-thumb-down"></span><span data-count="dislike">0</span></li><li class="act-btn" onclick="Global.nonlogin()" title="Поделилось с друзьями"><span class="mdi mdi-bullhorn"></span><span></span></li><li class="float-right"><button class="act-btn" onclick="$(&#39;body&#39;).share_social(&#39;https://evileg.com/ru/post/512/&#39;)" title="Поделиться ссылкой"><span class="mdi mdi-share-variant mdi-0"></span></button></li></ul></div></article><a class="anchor" id="comments"></a><div id="comments-feed"><a class="anchor" name="comment-2286"></a><div id="2286" class="card border-bottom"><div class="card-body"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/sapeg/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center piglet-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">s</div></div></div></a><div class="media-body"><ul class="list-inline mb-0"><li class="list-inline-item"><a rel="author" href="https://evileg.com/ru/users/sapeg/"><strong>sapeg</strong></a></li><li class="list-inline-item"><a href="https://evileg.com/ru/post/512/#comment-2286" title="Ссылка на комментарий">#</a></li><li class="list-inline-item text-muted mr-2"><small>6 декабря 2021 г. 21:51</small></li></ul><div class="e-text"><pre><pre class="prettyprint linenums prettyprinted" style=""><ol class="linenums"><li class="L0"><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">int</span><span class="pln"> i</span><span class="pun">=</span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i i </span><span class="pun">=</span><span class="pln"> adjLists</span><span class="pun">[</span><span class="pln">currVertex</span><span class="pun">].</span><span class="pln">listIterator</span><span class="pun">();</span></li></ol></pre></pre><p>
  это foreach или где?
 </p></div></div></div></div><ul class="card-footer act-footer"><li class="act-btn" onclick="Global.nonlogin()" title="Только зарегистрированные пользователи могут добавлять в избранное"><span data-icon="favorite" class="mdi mdi-star"></span><span data-count="favorite">0</span></li><li class="act-btn" onclick="Global.nonlogin()" title="Только зарегистрированные пользователи могут оценивать"><span data-icon="like" class="mdi mdi-thumb-up"></span><span data-count="like">0</span></li><li class="act-btn" onclick="Global.nonlogin()" title="Только зарегистрированные пользователи могут оценивать"><span data-icon="dislike" class="mdi mdi-thumb-down"></span><span data-count="dislike">0</span></li><li class="act-btn" onclick="Global.nonlogin()" title="Поделилось с друзьями"><span class="mdi mdi-bullhorn"></span><span></span></li><li class="float-right"><button class="act-btn" onclick="$(&#39;body&#39;).share_social(&#39;https://evileg.com/ru/post/512/#comment-2286&#39;)" title="Поделиться ссылкой"><span class="mdi mdi-share-variant mdi-0"></span></button></li></ul><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Comment", "author": "sapeg", "url": "/ru/post/512/#comment-2286", "name": "Поиск в ширину (Breadth first search, BFS)", "headline": "Поиск в ширину (Breadth first search, BFS)", "description": "\n  for (int i=0; i i = adjLists[currVertex].listIterator();\n\n \n  это foreach или где?\n \n", "datePublished": "2021-12-06T14:51:12.176412+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="card card-warning m-3 box-shadow"><div class="card-header bg-warning"><h3 class="card-title mb-0">Комментарии</h3></div><div class="card-body">
            
            
            Только авторизованные пользователи могут публиковать комментарии.<br>Пожалуйста, <a href="https://evileg.com/ru/accounts/login/">авторизуйтесь</a> или <a href="https://evileg.com/ru/accounts/register/">зарегистрируйтесь</a></div></div></div></div><div class="col-12 col-lg-3 p-0 pb-3 bg-light " style="height: auto !important; min-height: 0px !important;"><div class="card box-shadow m-2"><script async="" src="./Поиск в ширину (Breadth first search, BFS)_files/f(4).txt"></script><!-- Evileg COM Header --><ins class="adsbygoogle" style="display: block; height: 600px;" data-ad-client="ca-pub-8877856398367795" data-ad-slot="4753134862" data-ad-format="auto" data-full-width-responsive="true" data-adsbygoogle-status="done" data-ad-status="unfilled"><ins id="aswift_1_expand" style="border: none; height: 600px; width: 262px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;" tabindex="0" title="Advertisement" aria-label="Advertisement"><ins id="aswift_1_anchor" style="border: none; height: 600px; width: 262px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block; overflow: visible;"><iframe id="aswift_1" name="aswift_1" style="left:0;position:absolute;top:0;border:0;width:262px;height:600px" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="262" height="600" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="./Поиск в ширину (Breadth first search, BFS)_files/ads(1).html" data-google-container-id="a!2" data-google-query-id="CJSRyrLz-fYCFW5IkQUd8RMBPg" data-load-complete="true"></iframe></ins></ins></ins><script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script></div><div class="sticky" style="height: auto !important;"><div class="card box-shadow m-2"><h5 class="card-header text-center">Timeweb</h5><div class="card-body"><p>Позвольте мне порекомендовать вам отличный хостинг, на котором расположен EVILEG.</p><p>В течение многих лет Timeweb доказывает свою стабильность.</p><p>Для проектов на Django рекомендую VDS хостинг</p><a class="btn btn-outline-primary btn-block" href="https://timeweb.com/ru/?i=27415&amp;utm_source=evileg&amp;utm_medium=sidebar&amp;utm_campaign=ru" target="_blank" rel="nofollow">Посмотреть Хостинг</a></div></div><div class="card box-shadow m-2"><script async="" src="./Поиск в ширину (Breadth first search, BFS)_files/f(4).txt"></script><!-- Evileg COM Sidebar --><ins class="adsbygoogle" style="display: block; height: 0px;" data-ad-client="ca-pub-8877856398367795" data-ad-slot="7952216063" data-ad-format="auto" data-full-width-responsive="true" data-adsbygoogle-status="done" data-ad-status="unfilled"><ins id="aswift_2_expand" style="border: none; height: 0px; width: 262px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;" tabindex="0" title="Advertisement" aria-label="Advertisement"><ins id="aswift_2_anchor" style="border: none; height: 0px; width: 262px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block; overflow: hidden; opacity: 0;"><iframe id="aswift_2" name="aswift_2" style="left: 0px; position: absolute; top: 0px; border: 0px; width: 262px; height: 0px;" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="262" height="0" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="./Поиск в ширину (Breadth first search, BFS)_files/ads(2).html" data-google-container-id="a!3" data-google-query-id="CNy3z7Lz-fYCFQmxsgodXn4GIA" data-load-complete="true"></iframe></ins></ins></ins><script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script></div><div id="toTop" class="text-center mt-3 pt-3" style=""><button onclick="toTop()" class="btn btn-primary active">Наверх</button></div></div></div></main><div class="container-fluid bg-light"><div class="row"><div class="col-12 col-lg-9 px-0"><div class="card border-top box-shadow m-2"><div class="card-header"><div class="row"><a class="col-md-4" href="https://evileg.com/ru/tests/pt/recent/"><strong>Последние пройденные тесты</strong></a><a class="col-md-4" href="https://evileg.com/ru/tests/pt/rating/"><strong>Рейтинг</strong></a></div></div><div class="card-body"><div class="row"><div class="media col-md-4"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/Scandal1996/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center aqua-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">S</div></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/Scandal1996/"><strong>Scandal1996</strong></a></li><li class="list-inline-item text-muted mr-2"><small>1 апреля 2022 г. 23:56</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/tests/t/8/">C++ - Тест 006. Перечисления</a></p><ul class="list-inline mb-0"><li class="list-inline-item"><strong>Результат:</strong><span class="badge badge-light mx-1">50</span>баллов,</li><li class="list-inline-item">Очки рейтинга<span class="badge badge-light mx-1">-4</span></li><li class="list-inline-item"><span class="mdi mdi-close-outline text-danger mdi-0" title="Тест не сдан"></span></li></ul></div></div><div class="media col-md-4"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/Scandal1996/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center aqua-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">S</div></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/Scandal1996/"><strong>Scandal1996</strong></a></li><li class="list-inline-item text-muted mr-2"><small>1 апреля 2022 г. 23:52</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/tests/t/6/">C++ - Тест 004. Указатели, Массивы и Циклы</a></p><ul class="list-inline mb-0"><li class="list-inline-item"><strong>Результат:</strong><span class="badge badge-light mx-1">40</span>баллов,</li><li class="list-inline-item">Очки рейтинга<span class="badge badge-light mx-1">-8</span></li><li class="list-inline-item"><span class="mdi mdi-close-outline text-danger mdi-0" title="Тест не сдан"></span></li></ul></div></div><div class="media col-md-4"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/Scandal1996/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center aqua-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">S</div></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/Scandal1996/"><strong>Scandal1996</strong></a></li><li class="list-inline-item text-muted mr-2"><small>1 апреля 2022 г. 23:48</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/tests/t/1/">C++ - Тест 001. Первая программа и типы данных</a></p><ul class="list-inline mb-0"><li class="list-inline-item"><strong>Результат:</strong><span class="badge badge-light mx-1">93</span>баллов,</li><li class="list-inline-item">Очки рейтинга<span class="badge badge-light mx-1">8</span></li><li class="list-inline-item"><span class="mdi mdi-check-outline text-success mdi-0" title="Тест сдан"></span></li></ul></div></div></div></div></div><div class="card box-shadow m-2"><div class="card-header"><strong>Популярные публикации за последние 90 дней</strong></div><div class="card-body"><div class="py-1"><span class="badge badge-secondary float-right mdi mdi-eye">3.1K</span><a href="https://evileg.com/ru/post/658/">Django Rest Framework - Урок 001.  Добавление аутентификации по токену</a></div><div class="py-1"><span class="badge badge-secondary float-right mdi mdi-eye">1.2K</span><a href="https://evileg.com/ru/post/655/">Django - Урок 055.  Как написать функционал auto populate field</a></div><div class="py-1"><span class="badge badge-secondary float-right mdi mdi-eye">1.2K</span><a href="https://evileg.com/ru/post/656/">Django - Урок 056. Как конвертировать изображение в формат WEBP при сохранении в ImageField</a></div><div class="py-1"><span class="badge badge-secondary float-right mdi mdi-eye">1.1K</span><a href="https://evileg.com/ru/post/654/">Qt/C++ Урок 092. Создание переводов для внешних источников текста</a></div><div class="py-1"><span class="badge badge-secondary float-right mdi mdi-eye">795</span><a href="https://evileg.com/ru/post/657/">Django - Урок 057. Поддержка мультиязычности в MarkdownField с функционалом auto populate</a></div></div></div><div class="card box-shadow m-2"><div class="card-header"><strong>Последние комментарии</strong></div><div class="card-body"><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/skynetpro.ru/"><div class="m-0 p-0 position-relative"><div class="bg-white avatar-3 rounded-circle m-0 box-shadow"><img loading="lazy" class="avatar-3 rounded-circle m-0" src="./Поиск в ширину (Breadth first search, BFS)_files/avatar_iu7MhlX.jpg"></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/skynetpro.ru/"><strong>NSProject</strong></a></li><li class="list-inline-item text-muted mr-2"><small>3 апреля 2022 г. 1:06</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/post/246/#comment-2372">Django - Урок 023. Like Dislike система с помощью GenericForeignKey</a></p><div>   Меня интересует только один вопрос в плате SQL запросов. Их почему то плодится очень много с системой лайков и дизлайков </div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Comment", "author": "NSProject", "url": "/ru/post/246/#comment-2372", "name": "Django - Урок 023. Like Dislike система с помощью GenericForeignKey", "headline": "Django - Урок 023. Like Dislike система с помощью GenericForeignKey", "description": "\n \n  Меня интересует только один вопрос в плате SQL запросов. Их почему то плодится очень много с системой лайков и дизлайков\n \n", "datePublished": "2022-04-02T18:06:39.959208+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/skynetpro.ru/"><div class="m-0 p-0 position-relative"><div class="bg-white avatar-3 rounded-circle m-0 box-shadow"><img loading="lazy" class="avatar-3 rounded-circle m-0" src="./Поиск в ширину (Breadth first search, BFS)_files/avatar_iu7MhlX.jpg"></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/skynetpro.ru/"><strong>NSProject</strong></a></li><li class="list-inline-item text-muted mr-2"><small>3 апреля 2022 г. 1:03</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/post/546/#comment-2371">Django - Урок 048. Как добавить статус онлайн на сайте</a></p><div>   А вы создали в settings.py?  AUTH_USER_MODEL = 'you_app.User'   А так же во всех моделях где есть внешний ключ на юзера нужно ставить  settings.AUTH_USER_MODEL</div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Comment", "author": "NSProject", "url": "/ru/post/546/#comment-2371", "name": "Django - Урок 048. Как добавить статус онлайн на сайте", "headline": "Django - Урок 048. Как добавить статус онлайн на сайте", "description": "\n \n  А вы создали в settings.py?\n \n AUTH_USER_MODEL = 'you_app.User'\n\n \n  А так же во всех моделях где есть внешний ключ на юзера нужно ставить\n \n settings.AUTH_USER_MODEL\n\n", "datePublished": "2022-04-02T18:03:49.661899+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/Vitalii181190/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center sage-percuasion-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">V</div></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/Vitalii181190/"><strong>Vitalii181190</strong></a></li><li class="list-inline-item text-muted mr-2"><small>3 апреля 2022 г. 0:09</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/post/546/#comment-2370">Django - Урок 048. Как добавить статус онлайн на сайте</a></p><div>   Сделал всё как описано но при создании миграций возникает ошибка:    SystemCheckError: System check identified some issues:    ERRORS:    auth.User.groups: (fields.E304) Reverse accessor …</div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Comment", "author": "Vitalii181190", "url": "/ru/post/546/#comment-2370", "name": "Django - Урок 048. Как добавить статус онлайн на сайте", "headline": "Django - Урок 048. Как добавить статус онлайн на сайте", "description": "\n \n  Сделал всё как описано но при создании миграций возникает ошибка:\n  \n  SystemCheckError: System check identified some issues:\n \n \n  ERRORS:\n  \n  auth.User.groups: (fields.E304) Reverse accessor for 'auth.User.groups' clashes with reverse accessor for 'users.User.groups'.\n  \n  HINT: Add or change a related_name argument to the definition for 'auth.User.groups' or 'users.User.groups'.\n  \n  auth.User.user_permissions: (fields.E304) Reverse accessor for 'auth.User.user_permissions' clashes with reverse accessor for 'users.User.user_permissions'.\n  \n  HINT: Add or change a related_name argument to the definition for 'auth.User.user_permissions' or 'users.User.user_permissions'.\n  \n  users.User.groups: (fields.E304) Reverse accessor for 'users.User.groups' clashes with reverse accessor for 'auth.User.groups'.\n  \n  HINT: Add or change a related_name argument to the definition for 'users.User.groups' or 'auth.User.groups'.\n  \n  users.User.user_permissions: (fields.E304) Reverse accessor for 'users.User.user_permissions' clashes with reverse accessor for 'auth.User.user_permissions'.\n  \n  HINT: Add or change a related_name argument to the definition for 'users.User.user_permissions' or 'auth.User.user_permissions'.\n \n", "datePublished": "2022-04-02T17:09:18.891171+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/bycbo/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center aqua-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">b</div></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/bycbo/"><strong>bycbo</strong></a></li><li class="list-inline-item text-muted mr-2"><small>30 марта 2022 г. 3:16</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/post/77/#comment-2368">Qt/C++ - Урок 014. Динамическое создание виджетов в Qt</a></p><div>   а можно посмотреть финальный проект? Что-то не пойму что я делаю не так </div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Comment", "author": "bycbo", "url": "/ru/post/77/#comment-2368", "name": "Qt/C++ - Урок 014. Динамическое создание виджетов в Qt", "headline": "Qt/C++ - Урок 014. Динамическое создание виджетов в Qt", "description": "\n \n  а можно посмотреть финальный проект? Что-то не пойму что я делаю не так\n \n", "datePublished": "2022-03-29T20:16:56.309872+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/olegsemenchuk79/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center dark-knight-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">KR</div></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/olegsemenchuk79/"><strong>Kot Roth</strong></a></li><li class="list-inline-item text-muted mr-2"><small>28 марта 2022 г. 18:14</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/post/642/#comment-2367">5 Способов убрать ненужные символы из строки на Python</a></p><div>   помогло, спасибо </div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Comment", "author": "Kot Roth", "url": "/ru/post/642/#comment-2367", "name": "5 Способов убрать ненужные символы из строки на Python", "headline": "5 Способов убрать ненужные символы из строки на Python", "description": "\n \n  помогло, спасибо\n \n", "datePublished": "2022-03-28T11:14:36.242922+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div></div></div><div class="card box-shadow m-2"><div class="card-header"><strong>Сейчас обсуждают на форуме</strong></div><div class="card-body"><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/juvf/"><div class="m-0 p-0 position-relative"><div class="bg-white avatar-3 rounded-circle m-0 box-shadow"><img loading="lazy" class="avatar-3 rounded-circle m-0" src="./Поиск в ширину (Breadth first search, BFS)_files/avatar(1).jpg"></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/juvf/"><strong>juvf</strong></a></li><li class="list-inline-item text-muted mr-2"><small>1 апреля 2022 г. 18:12</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/forum/topic/1726/#post-9364">Виджет настройки</a></p><div>   ну про CoverFlow вобможно в будущем можно будет и визуализацию выпуклости (колеса) сделать, спсибо.    Сейчас пока нужен просто виджет настройки/регулировки.... Как это с помошью ScrollView р…</div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Answer", "author": "juvf", "url": "/ru/forum/topic/1726/#post-9364", "name": "Виджет настройки", "headline": "Виджет настройки", "description": "\n \n  ну про CoverFlow вобможно в будущем можно будет и визуализацию выпуклости (колеса) сделать, спсибо.\n \n \n  Сейчас пока нужен просто виджет настройки/регулировки.... Как это с помошью ScrollView реализовать? (рассмотрим горизонтальную ориентацию)\n  \n  Допустим я нарисую шкалу в png. ширина шкалы 500 пикселей. Сделаю ScrollView шириной 100 пикселей. Помещю в ScrollView картинку шкалы.\n  \n  Пальцем буду её двигать.... мне нужно как то зациклить. Протолкну шкалу по ScrollView до конца, а потом что?\n \n", "datePublished": "2022-04-01T11:12:52.568158+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/IscanderChe/"><div class="m-0 p-0 position-relative"><div class="bg-white avatar-3 rounded-circle m-0 box-shadow"><img loading="lazy" class="avatar-3 rounded-circle m-0" src="./Поиск в ширину (Breadth first search, BFS)_files/avatar(2).jpg"></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/IscanderChe/"><strong>IscanderChe</strong></a></li><li class="list-inline-item text-muted mr-2"><small>31 марта 2022 г. 1:06</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/forum/topic/1725/">Доступ по SSH по ключу</a></p><div>   Добрый день!    Подскажите, как настроить доступ по SSH по ключу, если сервер SSH крутится на Debian, а клиент - на Win 10?    Курение мануалов из сети, к сожалению, не помогло...    Де…</div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Question", "author": "IscanderChe", "url": "/ru/forum/topic/1725/", "name": "Доступ по SSH по ключу", "headline": "Доступ по SSH по ключу", "description": "\n \n  Добрый день!\n \n \n  Подскажите, как настроить доступ по SSH по ключу, если сервер SSH крутится на Debian, а клиент - на Win 10?\n \n \n  Курение мануалов из сети, к сожалению, не помогло...\n \n \n  Делал так.\n \n \n  На винде:\n  \n  ssh-keygen\n \n \n  На вопрос утилиты, куда сохранить, выбрал своё расположение. В папке %path_to_.ssh% появилось два файла: id_rsa.pub и id_rsa.\n \n \n  ssh-copy-id user@server\n \n \n  Ответ такой: \"'ssh-copy-id' is not recognized as an internal or external command, operable program or batch file.\"\n \n \n  Поэтому иду другим путём.\n \n \n  На линуксе через консоль винды:\n  \n  mkdir\n  \n   /.ssh\n   \n   chmod 0700\n  \n  /.ssh\n  \n  touch\n  \n   /.ssh/authorized_keys\n   \n   chmod 0644\n  \n  /.ssh/authorized_keys\n \n \n  Через консоль винды вставил ключ из id_rsa.pub и сохранил файл.\n  \n  Перезапустил сервис. Итог: всё равно требуется пароль. Настройка сервера \"PubkeyAuthentication yes\".\n \n \n  Через сервисы PuTTY заработало, но мне хотелось бы чисто через консоль винды.\n \n", "datePublished": "2022-03-30T18:06:32.170836+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/mihail.dark/"><div class="m-0 p-0 position-relative"><div class="bg-white avatar-3 rounded-circle m-0 box-shadow"><img loading="lazy" class="avatar-3 rounded-circle m-0" src="./Поиск в ширину (Breadth first search, BFS)_files/avatar(3).jpg"></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/mihail.dark/"><strong>Михаил Сермяжко</strong></a></li><li class="list-inline-item text-muted mr-2"><small>29 марта 2022 г. 15:42</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/forum/topic/1724/">Автоматически обновляться от QAbstractModel</a></p><div>   Добрый день.    Наследовал QAbstractModel на с++ и использую ее в QML. Как автоматом обновлять данные в QML при изменении данных в QAbstractModel?    Попробовал с помощью void emitSignalUpda…</div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Question", "author": "Михаил Сермяжко", "url": "/ru/forum/topic/1724/", "name": "Автоматически обновляться от QAbstractModel", "headline": "Автоматически обновляться от QAbstractModel", "description": "\n \n  Добрый день.\n  \n  Наследовал QAbstractModel на с++ и использую ее в QML. Как автоматом обновлять данные в QML при изменении данных в QAbstractModel?\n  \n  Попробовал с помощью void emitSignalUpdateModel();, но не получилось.\n \n \n  Q_PROPERTY для QML\n \n Q_PROPERTY(ModelRegistration* modelRegistration MEMBER m_modelRegistration CONSTANT)\n\n \n  .h\n \n #ifndef MODELREGISTRATION_H\n#define MODELREGISTRATION_H\n\n#include &lt;QObject&gt;\n#include &lt;QAbstractListModel&gt;\n\nstruct RegistrationObject\n{\n    RegistrationObject(int id, QString name, bool isDone) {\n        m_id = id;\n        m_name = name;\n        m_isDone = isDone;\n    }\n    int m_id;\n    QString m_name;\n    bool m_isDone;\n};\n\nclass ModelRegistration : public QAbstractListModel\n{\n    Q_OBJECT\npublic:\n    ModelRegistration(QObject *parent = nullptr);\n\n    enum RoleNames {\n        IdRole = Qt::UserRole,\n        NameRole,\n        IsDoneRole\n    };\n\n    QVector&lt;RegistrationObject&gt; vectorDataRegistration;\n\n    int rowCount(const QModelIndex&amp; parent = QModelIndex()) const override;\n    QVariant data(const QModelIndex&amp; index, int role = Qt::DisplayRole) const override;\n\npublic slots:\n    void emitSignalUpdateModel();\n\nprotected:\n    QHash&lt;int, QByteArray&gt; roleNames() const override;\n};\n\n#endif // MODELREGISTRATION_H\n\n \n  .cpp\n \n #include \"modelregistration.h\"\n\nModelRegistration::ModelRegistration(QObject *parent) : QAbstractListModel(parent)\n{\n    vectorDataRegistration.append(RegistrationObject(1, \"Legs (back)\", false));\n    vectorDataRegistration.append(RegistrationObject(2, \"Hips (back)\", false));\n    vectorDataRegistration.append(RegistrationObject(3, \"Back\", false));\n    vectorDataRegistration.append(RegistrationObject(3, \"Arms (back)\", false));\n    vectorDataRegistration.append(RegistrationObject(3, \"Hips (front)\", false));\n    vectorDataRegistration.append(RegistrationObject(4, \"Belly\", false));\n    vectorDataRegistration.append(RegistrationObject(3, \"Arms (front)\", false));\n}\n\nint ModelRegistration::rowCount(const QModelIndex &amp;parent) const\n{\n    return vectorDataRegistration.count();\n}\n\nQVariant ModelRegistration::data(const QModelIndex &amp;index, int role) const\n{\n    if (index.row() &lt; 0 || index.row() &gt;= vectorDataRegistration.count())\n        return QVariant();\n\n    switch (role)\n    {\n    case IdRole:\n        return vectorDataRegistration[index.row()].m_id;\n    case NameRole:\n        return vectorDataRegistration[index.row()].m_name;\n    case IsDoneRole:\n        return vectorDataRegistration[index.row()].m_isDone;\n    }\n\n    return QVariant();\n}\n\nvoid ModelRegistration::emitSignalUpdateModel()\n{\n    auto index = this-&gt;index(0);\n    emit dataChanged(index, index, QVector&lt;int&gt;{0,1,2});\n}\n\nQHash&lt;int, QByteArray&gt; ModelRegistration::roleNames() const\n{\n    QHash&lt;int, QByteArray&gt; roles;\n    roles[IdRole] = \"id\";\n    roles[NameRole] = \"name\";\n    roles[IsDoneRole] = \"isDone\";\n    return roles;\n}\n\n\n", "datePublished": "2022-03-29T08:42:29.265149+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/chunk/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center virgin-amerika-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">ИМ</div></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/chunk/"><strong>Игорь Максимов</strong></a></li><li class="list-inline-item text-muted mr-2"><small>29 марта 2022 г. 2:53</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/forum/topic/1721/#post-9360">Прикрутить форму к админ-панели</a></p><div>   Между вывом кодирования из модели и из формы </div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Answer", "author": "Игорь Максимов", "url": "/ru/forum/topic/1721/#post-9360", "name": "Прикрутить форму к админ-панели", "headline": "Прикрутить форму к админ-панели", "description": "\n \n  Между вывом кодирования из модели и из формы\n \n", "datePublished": "2022-03-28T19:53:48.303311+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="py-2"><div class="media"><a class="mr-3 text-decoration-none" href="https://evileg.com/ru/users/Jamesglupe/"><div class="m-0 p-0 position-relative"><div class="avatar-3 rounded-circle m-0 text-center dark-knight-gradient box-shadow"><div class="text-center align-middle w-100 h-100 avatar-initials text-uppercase avatar-initials-size-3">J</div></div></div></a><div class="media-body"><ul class="list-inline mb-1"><li class="list-inline-item"><a href="https://evileg.com/ru/users/Jamesglupe/"><strong>Jamesglupe</strong></a></li><li class="list-inline-item text-muted mr-2"><small>25 марта 2022 г. 8:27</small></li></ul><p class="mb-1"><a href="https://evileg.com/ru/forum/topic/1692/#post-9341">Sorting the added QML elements in the ListModel</a></p><div>   Free slot play no download no registration  п»ї     gamesforrealmoney    usa online casino no deposit bonus code    Dead or alive 2 slot free play     freeslotgameswithbonusspins.blogspo…</div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Answer", "author": "Jamesglupe", "url": "/ru/forum/topic/1692/#post-9341", "name": "Sorting the added QML elements in the ListModel", "headline": "Sorting the added QML elements in the ListModel", "description": "\n \n  Free slot play no download no registration  п»ї\n  \n   gamesforrealmoney\n  \n  usa online casino no deposit bonus code\n  \n  Dead or alive 2 slot free play\n  \n   freeslotgameswithbonusspins.blogspot.com\n  \n  online casino free signup bonus no deposit required nz\n  \n  How to play poker in sleeping dogs\n  \n   slotmachinerealmoney.blogspot.com\n  \n  thunderbolt casino no deposit bonus codes 2021\n  \n  Automatenspiele kostenlos spielen ohne anmeldung book of ra\n  \n   bestslotsplaywheelingisland.blogspot.com\n  \n  free online casino win real money no deposit\n  \n  Free slots machines games to play online\n  \n   bestcasinosinlasvegas.blogspot.com\n  \n  casinos online 888 free casino games slot machines\n  \n  Kronos father of zeus slot machine free play\n  \n   slotmachineunderstanding.blogspot.com\n  \n  house of fun slots casino similar games\n  \n   https://klopslin.wixsite.com/play-poker-online\n  \n \n \n  \n   meeting online dating\n  \n \n", "datePublished": "2022-03-25T01:27:57.483642+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div></div></div></div><div class="col-12 col-lg-3 p-0 pb-3"><div class="sticky"><div class="card box-shadow m-2"><script async="" src="./Поиск в ширину (Breadth first search, BFS)_files/f(4).txt"></script><!-- EVILEG COM Bottom --><ins class="adsbygoogle" style="display: block; height: 600px;" data-ad-client="ca-pub-8877856398367795" data-ad-slot="4520850861" data-ad-format="auto" data-full-width-responsive="true" data-adsbygoogle-status="done"><ins id="aswift_3_expand" style="border: none; height: 600px; width: 262px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;"><ins id="aswift_3_anchor" style="border: none; height: 600px; width: 262px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block;"></ins></ins></ins><script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script></div><!-- Yandex.RTB R-A-218837-2 --><div id="yandex_rtb_R-A-218837-2"><yatag class="hbcc49563 ica4f4aee"><yatag class="h7b9b479e"></yatag><yatag class="d4a383bae q60033086 c6062fc1a"><yatag class="g45379729" style="width: 240px !important; height: 600px !important;"><yatag id="ya_partner_R-A-218837-2" class="e927bf79e" style="width: 240px !important; height: 600px !important; transform: none !important;"><yatag class="keccaa516 hb7f535f1" data-label="true"><yatag data-test="AdKebabAndLabel--adLabelBg" class="i92e83db3"></yatag>Реклама</yatag><yatag class="p98e7ad81 xddd34c87 w1237f987"><yatag data-close="true" data-new-adtune="true" class="ee9c6d55f kaea8864a hb7f535f1 g19836842"><yatag class="nda367efa"></yatag><yatag class="s719bafb4"><svg width="8" height="20" fill="#fff" xmlns="http://www.w3.org/2000/svg"><circle cx="4" cy="4" r="1.5"></circle><circle cx="4" cy="10" r="1.5"></circle><circle cx="4" cy="16" r="1.5"></circle></svg></yatag></yatag></yatag><iframe frameborder="no" scrolling="no" allowtransparency="true" hidefocus="true" tabindex="-1" marginwidth="0" marginheight="0" src="./Поиск в ширину (Breadth first search, BFS)_files/render.html" sandbox="allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-scripts allow-forms" id="id5079" style="opacity: 1;"></iframe></yatag></yatag></yatag></yatag></div><script type="text/javascript">
    (function(w, d, n, s, t) {
        w[n] = w[n] || [];
        w[n].push(function() {
            Ya.Context.AdvManager.render({
                blockId: "R-A-218837-2",
                renderTo: "yandex_rtb_R-A-218837-2",
                async: true
            });
        });
        t = d.getElementsByTagName("script")[0];
        s = d.createElement("script");
        s.type = "text/javascript";
        s.src = "//an.yandex.ru/system/context.js";
        s.async = true;
        t.parentNode.insertBefore(s, t);
    })(this, this.document, "yandexContextAsyncCallbacks");
</script></div></div></div></div><div class="container-fluid px-0 mx-0 py-3 row border-top small"><div class="col-12 col-lg-2"><h6>О нас</h6><ul class="fl"><li><a href="https://evileg.com/ru/pages/" target="_self">О сайте</a></li><li><a href="https://evileg.com/ru/pages/rules/privacy-policy/">Политика конфиденциальности</a></li><li><a href="https://evileg.com/ru/pages/contacts/">Контакты</a></li><li><a href="https://evileg.com/docs/evileg_core/" target="_blank">Документация</a></li><li><a href="https://github.com/EVILEG" target="_blank" rel="nofollow">GitHub</a></li><li><a href="https://evileg.com/ru/pages/donate/">Donate</a></li></ul></div><div class="col-12 col-lg-2"><h6>Услуги</h6><ul class="fl"><li><a href="https://evileg.com/ru/pages/for-advertisers/">Для рекламодателей</a></li></ul></div><div class="col-12 col-lg-2"><div class="mb-1">© EVILEG 2015-2021<br>Рекомендует хостинг <a href="http://timeweb.com/ru/?i=27415" target="_blank" rel="nofollow">TIMEWEB</a></div><a href="https://vk.com/evileg" class="vk-color" title="VK" rel="nofollow noopener noreferrer" target="_blank"><span class="mdi mdi-36px mdi-vk-box mdi-0"></span></a><a href="https://github.com/EVILEG" class="github-color" title="GitHub" rel="nofollow noopener noreferrer" target="_blank"><span class="mdi mdi-36px mdi-github-box mdi-0"></span></a><a href="https://www.youtube.com/c/EVILEG" class="youtube-color" title="YouTube" rel="nofollow noopener noreferrer" target="_blank"><span class="mdi mdi-36px mdi-youtube mdi-0"></span></a></div></div><script defer="" src="./Поиск в ширину (Breadth first search, BFS)_files/prettify.js"></script><script defer="" src="./Поиск в ширину (Breadth first search, BFS)_files/metrika.min.js"></script><noscript><img src="https://mc.yandex.ru/watch/39565770" style="position:absolute; left:-9999px;" alt="" /></noscript><div class="modal fade" id="share_on_social_networks" tabindex="-1" aria-hidden="true"><div class="modal-dialog modal-lg w-auto modal-content"><div class="modal-header"><span>Поделиться в социальных сетях</span><span class="mdi mdi-24px mdi-window-close mdi-0 pointer" data-dismiss="modal" aria-label="Close"></span></div><div class="modal-body"><a id="share_vk" href="https://evileg.com/ru/post/512/#" class="btn btn-dark btn-menu" target="_blank" rel="nofollow" onclick="window.open(this.href, &#39;Поделиться ссылкой в ВКонтакте&#39;, &#39;width=800,height=300&#39;); pages.clearCache(this.href); return false;"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-vk-box mdi-0"></span></div><small>VKontakte</small></div></div></a><a id="share_facebook" href="https://evileg.com/ru/post/512/#" class="btn btn-dark btn-menu" target="_blank" rel="nofollow" onclick="window.open(this.href, &#39;Поделиться ссылкой в Facebook&#39;, &#39;width=640,height=436,toolbar=0,status=0&#39;); return false;"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-facebook-box mdi-0"></span></div><small>Facebook</small></div></div></a><a id="share_twitter" href="https://evileg.com/ru/post/512/#" class="btn btn-dark btn-menu" target="_blank" rel="nofollow" onclick="window.open(this.href, &#39;Поделиться ссылкой в Twitter&#39;); return false;"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-twitter-box mdi-0"></span></div><small>Twitter</small></div></div></a><a id="share_linkedin" href="https://evileg.com/ru/post/512/#" class="btn btn-dark btn-menu" target="_blank" rel="nofollow" onclick="window.open(this.href, &#39;Поделиться ссылкой в LinkedIn&#39;, &#39;width=800,height=600&#39;); return false;"><div class="btn-menu-body"><div class="btn-menu-center"><div class="btn-menu-icon-offset"><span class="mdi mdi-36px mdi-linkedin-box mdi-0"></span></div><small>LinkedIn</small></div></div></a></div></div></div><div id="shadow" class="shadow" onclick="$(&#39;body&#39;).toggleDrawer();"></div>
<ins class="adsbygoogle adsbygoogle-noablate" data-adsbygoogle-status="done" style="display: none !important;" data-ad-status="unfilled"><ins id="aswift_4_expand" style="border: none; height: 0px; width: 0px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;" tabindex="0" title="Advertisement" aria-label="Advertisement"><ins id="aswift_4_anchor" style="border: none; height: 0px; width: 0px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block;"><iframe id="aswift_4" name="aswift_4" style="left:0;position:absolute;top:0;border:0;width:undefinedpx;height:undefinedpx" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="./Поиск в ширину (Breadth first search, BFS)_files/ads(3).html" data-google-container-id="a!5" data-load-complete="true"></iframe></ins></ins></ins><div style="position: fixed; left: -99px;"><div id="7f73ea1177"><iframe frameborder="no" scrolling="no" allowtransparency="true" hidefocus="true" tabindex="-1" marginwidth="0" marginheight="0" src="./Поиск в ширину (Breadth first search, BFS)_files/render(1).html" id="id6875" style="opacity: 1;"></iframe></div></div><iframe src="./Поиск в ширину (Breadth first search, BFS)_files/aframe.html" width="0" height="0" style="display: none;"></iframe></body><style id="stylus-1" type="text/css" class="stylus">body {
    font-family: 'pragmata pro mono regular';
}</style><iframe id="google_esf" name="google_esf" src="./Поиск в ширину (Breadth first search, BFS)_files/zrt_lookup.html" style="display: none;"></iframe></html>